0

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?

Community
  • 1
  • 1
L. Blanc
  • 2,150
  • 2
  • 21
  • 31

1 Answers1

3

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));
mindas
  • 26,463
  • 15
  • 97
  • 154