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

后端 未结 2 913
温柔的废话
温柔的废话 2020-12-30 05:01

Will someone please explain under what circumstance I may use Field.Store.NO instead of Field.Store.YES? I am extremely new to Lucene. And I am try

相关标签:
2条回答
  • 2020-12-30 05:26

    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/

    0 讨论(0)
  • 2020-12-30 05:40

    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.

    0 讨论(0)
提交回复
热议问题