Storing Mode
Edit pageThe _store option decides whether a field’s value is kept in the stored document. It is a
boolean set per field, and it is independent of _index: a field with
"_store": false is still indexed, so it is searched, sorted and aggregated as usual, but
its value is not in the document that a GET or a search hit returns. Use it for values that
only need to be matched, such as text that is large or private.
The default is true.
Inheritance
Section titled “Inheritance”A field inherits _store from its parent, and a child can only turn it off: a field is
stored when its own _store is true and its parent is stored. Once a field is
"_store": false, everything under it stays unstored, even a child that sets
"_store": true. Sources: Schema::feed_store (src/database/schema.cc).
Parent _store | Field _store | Field is stored |
|---|---|---|
true | true | yes |
true | false | no |
false | true | no |
false | false | no |
Example
Section titled “Example”The secret field below is indexed but not stored. The profile object turns _store off for
itself, so its note field is unstored even though it asks for "_store": true; title
keeps the default:
PUT /test_store/
{ "_schema": { "title": { "_type": "text" }, "secret": { "_type": "text", "_store": false }, "profile": { "_type": "object", "_store": false, "note": { "_type": "text", "_store": true } } }}PUT /test_store/1
{ "title": "visible heading", "secret": "hidden passphrase", "profile": { "note": "private remark" }}The field matches a search
Section titled “The field matches a search”An unstored field is still indexed, so it matches a query by its name:
SEARCH /test_store/
{ "_query": { "secret": "passphrase" }}The hit carries the stored fields only:
SEARCH /test_store/
{ "_query": { "secret": "passphrase" }}The GET body lacks the field
Section titled “The GET body lacks the field”GET /test_store/1A child under _store: false stays unstored
Section titled “A child under _store: false stays unstored”The note field asked for "_store": true, but its parent profile is unstored, so
the GET body has no note:
GET /test_store/1It is still indexed, so it matches a search by its path:
SEARCH /test_store/
{ "_query": { "profile.note": "remark" }}