Advertisement
NLinker

Building lucene index with long and int fields

Jul 30th, 2014
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.18 KB | None | 0 0
  1. private static Document buildDocument(SiteProduct siteProduct) {
  2.         Document doc = new Document();
  3.         IndexableField siteProductIdF = new LongField("siteProductId",
  4.                 siteProduct.getSiteProductId(), Field.Store.YES);
  5.         IndexableField siteIdF = new IntField("siteId",
  6.                 siteProduct.getSiteId(), Field.Store.YES);
  7.         IndexableField nameF = new StringField("name",
  8.                 siteProduct.getName(), Field.Store.NO);
  9.         IndexableField categoryF = new StringField("category",
  10.                 StringUtils.lowerCase(siteProduct.getCategory()), Field.Store.YES);
  11.         doc.add(siteProductIdF);
  12.         doc.add(siteIdF);
  13.         doc.add(nameF);
  14.         doc.add(categoryF);
  15.         //((Field) doc.getField(siteProductIdField.name())).setStringValue(siteProduct.getSiteProductId().toString());
  16.         //((Field) doc.getField(siteIdField.name())).setStringValue(siteProduct.getSiteId().toString());
  17.         //((Field) doc.getField(nameField.name())).setStringValue(siteProduct.getName());
  18.         //((Field) doc.getField(categoryField.name())).setStringValue(StringUtils.lowerCase(siteProduct.getCategory()));
  19.         return doc;
  20.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement