the store attribute of a lucene field

前端 未结 2 917
灰色年华
灰色年华 2021-02-02 17:02

There is a constructor of lucene Field:

Field(String name, String value, Store store, Index index)

For example I can create a new field by:

相关标签:
2条回答
  • 2021-02-02 17:35

    As mentioned in Lucene FAQ:

    What is the different between Stored, Tokenized, Indexed, and Vector?

    • Stored = as-is value stored in the Lucene index
    • Tokenized = field is analyzed using the specified Analyzer - the tokens emitted are indexed
    • Indexed = the text (either as-is with keyword fields, or the tokens from tokenized fields) is made searchable (aka inverted)
    • Vectored = term frequency per document is stored in the index in an easily retrievable fashion.

    You can just index field content without store it, the field is also searchable, just can't highlight the result, because highlight requires original message content, which should Store.

    0 讨论(0)
  • 2021-02-02 17:46

    Stored fields are what is returned when you ask Lucene to give you back a document. They hold the original value of a field, with no analysis. You can use them to present the document to the users (not necessarily all fields).

    Stored fields that are not indexed are useful to store meta-data about a document that the user won't use to query the index. An example might be a database id where a document comes from. This id will never be used by the user since they does not know about it, so it is generally useless to index it. But if you store it, so you can use it to gather extra information from your db at runtime.

    The difference between a query and a search is rather subjective. For myself, a search is really the general act of searching in the index while a query is the actual query string used to search the index.

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