Reputation: 2310
This question has been asked and answered previously (link below), but the answer is obsolete.
I want to use Lucene to index a document with a boolean field. The way recommended in the prior post is:
doc.add(new Field("boolean","true",Field.Store.NO,Field.Index.NOT_ANALYZED_NO_NORMS));
However, the class Field is now deprecated. What's the best way to do this today?
Which is the best choice to indexing a Boolean value in lucene?
Upvotes: 0
Views: 930
Reputation: 26713
This
doc.add(new Field("boolean","true",Field.Store.NO,Field.Index.NOT_ANALYZED_NO_NORMS));
simply adds a non-analyzed string field having value "true".
StringField
should do the same trick these days:
doc.add(new StringField("boolean", "true", Store.NO));
Upvotes: 3