简体   繁体   中英

the store attribute of a lucene field

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:

Field f1 = new Field("text", "The text content", Field.Store.YES, Field.Index.ANALYZED);

I am not exactly sure of the meaning of the fourth parameter: Index

If I set it to Index.No ,so is it needed to add this field as a "field"?

Since in my opinion,once a attribute is declared as a field, it should be Indexed,if not then why do you declare it as a field?

What is the difference between query and search?

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM