Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

lucene

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 trying to create a document. Per my basic knowledge, I am doing

doc.add(new StringField(fieldNameA,fieldValueA,Field.Store.YES));
doc.add(new TextField(fieldNameB,fieldValueB,Field.Store.YES));
like image 938
Katedral Pillon Avatar asked Oct 05 '15 02:10

Katedral Pillon


People also ask

What are fields in lucene?

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 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 DB?

Lucene Core is a Java library providing powerful indexing and search features, as well as spellchecking, hit highlighting and advanced analysis/tokenization capabilities.


1 Answers

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.

like image 93
femtoRgon Avatar answered Sep 21 '22 07:09

femtoRgon