How get the document field when disable the _source?


#1

Hi,

I'm trying to disable _source as in my case the updated and reindex are unnecessary feature.
The issue is I cannot get any field when the _source is diabled.

I created a index like:
curl -XPUT http://localhost:9200/test1 -d '{"mappings":{"test":{"_source":{"enabled": false}}}}'
{"acknowledged":true}
and put a document in:
curl -XPUT http://localhost:9200/test1/test/1 -d '{"f1":"1111","f2":"222"}'
{"_index":"test1","_type":"test","_id":"1","_version":1,"created":true}

when try to get this document only the meta field returned
curl -XGET http://localhost:9200/test1/test/1
{"_index":"test1","_type":"test","_id":"1","_version":1,"found":true}

Is there something wrong?

Thanks


(Colin Goodheart-Smithe) #2

There is nothing wrong, Elasticsearch is working as expected. The field values are stored in the _source field and when you get a document this is what is returned. If you disable _source no fields will be stored and therefore will not be shown on a get request. You need to re-enable your _source field. Disabling the _source field is generally not recommend as is only useful in instances where you never need the stored values of the fields.


#3

Hi Colin

Thanks for your answers. Seems I need to manally controle which field need to be store if the _source was disabled, right?

Thanks a lot.


(Mark Walkom) #4

Correct, but why not store _source?


#5

For insert performance concern. As elasticsearch generate lots of extra inform far beyond the docment itself, I'd like to disable them which feature I didn't need.
But seems the _source is the one I need.


(system) #6