Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 690
hguser Avatar asked Nov 15 '10 03:11

hguser


People also ask

How does Lucene store data?

Lucene's “doc values” is basically a hack that takes advantage of Cassandra-style “columnar” data storage. We store all the document values in a simple format on-disk. Basically, in flat files.

How does Lucene store index?

A Lucene Index Is an Inverted Index An index may store a heterogeneous set of documents, with any number of different fields that may vary by a document in arbitrary ways. Lucene indexes terms, which means that Lucene search searches over terms. A term combines a field name with a token.

What is Lucene field?

A field is a section of a Document. Each field has three parts: name, type and value. Values may be text (String, Reader or pre-analyzed TokenStream), binary (byte[]), or numeric (a Number). Fields are optionally stored in the index, so that they may be returned with hits on the document.

How does Lucene Query work?

Simply put, Lucene uses an “inverted indexing” of data – instead of mapping pages to keywords, it maps keywords to pages just like a glossary at the end of any book. This allows for faster search responses, as it searches through an index, instead of searching through text directly.


1 Answers

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.

like image 85
Pascal Dimassimo Avatar answered Oct 28 '22 09:10

Pascal Dimassimo