Lucene Field.Store.YES versus Field.Store.NO

Use Field.Store.YES when you need a document back from Lucene document. Use NO when you just need a search from document. Here is a link explained with a scenario. https://handyopinion.com/java-lucene-saving-fields-or-not/


There are two basic ways a document can be written into Lucene.

  • Indexed - The field is analyzed and indexed, and can be searched.
  • Stored - The field's full text is stored and will be returned with search results.

If a document is indexed but not stored, you can search for it, but it won't be returned with search results.

One reasonably common pattern is to use lucene for search, but only have an ID field being stored which can be used to retrieve the full contents of the document/record from, for instance, a SQL database, a file system, or an web resource.

You might also opt not to store a field when that field is just a search tool, but you wouldn't display it to the user, such as a soundex/metaphone, or an alternate analysis of a content field.

Tags:

Lucene