Reputation: 43
What is the best way to add fields to a document now that Field.Index is deprecated.
Here is what I am doing and what most example online suggest:
doc.add(new Field("id", dbID, Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));
What is the new recommended way to set Index properties on Fields with Field.Index going away?
Upvotes: 4
Views: 2493
Reputation: 550
Use org.apache.lucene.document.StoredField
for the fields that you don’t want to index.
Refer
http://lucene.apache.org/core/4_6_0/core/org/apache/lucene/document/StoredField.html
to know about the various available constructors.
example:
StoredField strField = new StoredField("id", bag.getId());
Hope it helps.
Upvotes: 7