Tag Archives: Lucene

ElasticSearch save field explained !

If you are storing a document in elasticsearch having a field (name:word press) and you don’t want to store this field,but you can still retrieve the field if you have not disabled the _source (Enabled by default)

Elasticsearch by default saves every document that you send to it and therefore is able to give it back when requested . On the other hand Lucene has some kind of storage where you can store the fields that you want to get retrieved when a document ID is provided.

For example if the follwoing document is indexed in ES with I1 as index name with _source enabled(store is disabled by default)
name:”amit hora”,

When you query in a way to get all the documents having name=”a*” you will get the above document the reason being ES by default having _source field enabled and returns it with query in this case it will parse the document and will return the name field in doc having value as “a*”

while if you had _source field disabled you have to store the name field explicitly to be searched and retrieved when requested

Keep in mind though that retrieving many stored fields from lucene might require one disk seek per field while with retrieving only the _source from lucene and parsing it in order to retrieve the needed fields is just a single disk seek