Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding non-indexable fields to the document in lucene - Field.Index deprecated

Tags:

lucene

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?

like image 890
Hitesh Avatar asked Mar 21 '23 22:03

Hitesh


1 Answers

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.

like image 76
vaibhav Avatar answered Apr 27 '23 16:04

vaibhav