# \_source field in Elasticsearch

**URL:** <https://discuss.elastic.co/t/-source-field-in-elasticsearch/13626>\
**Category:** Elasticsearch\
**Created:** [September 16, 2013, 6:10pm UTC](https://discuss.elastic.co/t/-source-field-in-elasticsearch/13626 "2013-09-16T18:10:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pranav\_amin](https://avatars.discourse-cdn.com/v4/letter/p/a183cd/32.png) [@pranav\_amin](https://discuss.elastic.co/u/pranav_amin)\
**Post date:** [September 16, 2013, 6:10pm UTC](https://discuss.elastic.co/t/-source-field-in-elasticsearch/13626/1 "2013-09-16T18:10:26Z")

</div>

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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![drewr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drewr/32/7803_2.png) [@drewr](https://discuss.elastic.co/u/drewr)\
**Post date:** [September 16, 2013, 6:21pm UTC](https://discuss.elastic.co/t/-source-field-in-elasticsearch/13626/2 "2013-09-16T18:21:07Z")

</div>

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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 2:16am UTC](https://discuss.elastic.co/t/-source-field-in-elasticsearch/13626/3 "2017-07-06T02:16:15Z")

</div>


