_source field in Elasticsearch

Can someone explain the difference between _source field present vs not
present in an index?

I tried one example but couldn't figure out what difference does it make to
have or not have _source field -

_SOURCE FIELD ADDED IN MAPPING:

drwxrwxr-x 2 local local 4096 Sep 16 17:00 logs
local@pldsvv-07:/var/elasticsearch/elasticsearch-0.90.3$ curl -XDELETE
localhost:9200/test
{"ok":true,"acknowledged":true}local@pldsvv-07:/var/elasticsearch/elasticsearch-0.90.3$
curl -XPOST localhost:9200/test -d '{
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"type1" : {
"_source" : { "enabled" : true },
"properties" : {
"field1" : { "type" : "string", "index" : "not_analyzed" }
}
}
}
}'
{"ok":true,"acknowledged":true}local@pldsvv-07:/var/elasticsearch/elasticsearch-0.90.3$
local@pldsvv-07:/var/elasticsearch/elasticsearch-0.90.3$

SEARCHING SHOWS _SOURCE FIELD IS THERE -

/elasticsearch-0.90.3$ curl -XGET localhost:9200/test/test/_search?q=key:"2"
{"took":9,"timed_out":false,"_shards":{"total":1,"successful":1,"failed":0},"hits":{"total":1,"max_score":0.19178301,"hits":[{"_index":"test","_type":"test","_id":"2","_score":0.19178301,
"_source" :
{"key":"value
2"}}]}}local@pldsvv-07:/var/elasticsearch/elasticsearch-0.90.3$

MAKING _SOURCE FIELD FALSE NOW -

local@pldsvv-07:/var/elasticsearch/elasticsearch-0.90.3$
local@pldsvv-07:/var/elasticsearch/elasticsearch-0.90.3$ curl -XDELETE
localhost:9200/test
{"ok":true,"acknowledged":true}local@pldsvv-07:/var/elasticsearch/elasticsearch-0.90.3$
curl -XPOST localhost:9200/test -d '{
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"type1" : {
"_source" : { "enabled" : false },
"properties" : {
"field1" : { "type" : "string", "index" : "not_analyzed" }
}
}
}
}'
{"ok":true,"acknowledged":true}local@pldsvv-07:/var/elasticsearch/elasticsearch-0.90.3$
local@pldsvv-07:/var/elasticsearch/elasticsearch-0.90.3$
local@pldsvv-07:/var/elasticsearch/elasticsearch-0.90.3$ curl -XPUT
localhost:9200/test/test/2 -d '{"key":"value 2"}'
{"ok":true,"_index":"test","_type":"test","_id":"2","_version":1}local@pldsvv-07:/var/elasticsearch/elasticsearch-0.90.3$
local@pldsvv-07:/var/elasticsearch/elasticsearch-0.90.3$

SEARCHING AGAIN - STILL _SOURCE FIELD IS THERE

local@pldsvv-07:/var/elasticsearch/elasticsearch-0.90.3$ curl -XGET
localhost:9200/test/test/_search?q=key:"2"
{"took":2,"timed_out":false,"_shards":{"total":1,"successful":1,"failed":0},"hits":{"total":1,"max_score":0.19178301,"hits":[{"_index":"test","_type":"test","_id":"2","_score":0.19178301,
"_source" : {"key":"value
2"}}]}}local@pldsvv-07:/var/elasticsearch/elasticsearch-0.90.3$

Not sure what i achieved by adding or making it false. If someone can
explain it would be great.

Thanks

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

pranav amin wrote:

Can someone explain the difference between _source field present
vs not
present in an index?

I tried one example but couldn't figure out what difference does
it make to
have or not have _source field -

_SOURCE FIELD ADDED IN MAPPING:

[...]

        "_source" : { "enabled" : true },

This is an index-time setting. If you index a doc with _source
enabled, its _source is stored for good and will show up in search
results unless you use the fields parameter.

Drew

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.