user3019766
user3019766

Reputation: 131

why did elasticsearch designed "store" field?

By default, field values are indexed to make them searchable, but they are not stored. This means that the field can be queried, but the original field value cannot be retrieved.

I am curious how does the implementation work on Elasticsearch backend works. How can they make a value not retrievable but searchable? (I would imagine it would need to be stored somewhere in order for you to search it right?) Why is Elasticsearch designed this way? what efficiency did it achieve for designing it this way?

Upvotes: 0

Views: 104

Answers (1)

Val
Val

Reputation: 217304

The source document is actually "stored" in the _source field (but it is not indexed) and all fields of the source documents are indexed (but not stored). All field values can usually be retrieved from the _source field using source filtering. This is how ES is configured by default, but you're free to change that.

You can, for instance, decide to not store the _source document at all and store only certain fields of your document. This might be a good idea if for instance your document has a field which contains a huge blob of text. It might not be wise to store the _source because that would take a lot of space for nothing. That huge blob of text might only be useful for full-text search and so would only need to be indexed, while all other fields might need to be indexed and stored as well because they need to be retrieved in order to be displayed.

So the bottom line is:

  • if a field can be searched, it doesn't need to be stored, it only needs to be indexed
  • if a field can be retrieved, it can either be configured to be stored or retrieved/filtered from the _source field (which is stored by default)

Upvotes: 1

Related Questions