# Disabling \_source and using stored fields

**URL:** <https://discuss.elastic.co/t/disabling--source-and-using-stored-fields/20679>\
**Category:** Elasticsearch\
**Created:** [November 11, 2014, 6:27am UTC](https://discuss.elastic.co/t/disabling--source-and-using-stored-fields/20679 "2014-11-11T06:27:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peter\_van\_der\_Weerd](https://avatars.discourse-cdn.com/v4/letter/p/e99b99/32.png) [@Peter\_van\_der\_Weerd](https://discuss.elastic.co/u/Peter_van_der_Weerd)\
**Post date:** [November 11, 2014, 6:27am UTC](https://discuss.elastic.co/t/disabling--source-and-using-stored-fields/20679/1 "2014-11-11T06:27:24Z")

</div>

Hi,

I have a use case of very large documents (size\>10MB) where the metadata  
(title, author, etc) is small.  
I thought it could be beneficial to separate the body from the metadata and  
use different fields for them, because in a result list, you typically only  
need the metadata.  
So, I disabled the \_source field and stored both the body as the metadata  
as fields.

However, while storing and indexing works as expected, I'm not able to get  
my data back.  
Complex fields (ie objects) cannot be retrieved and return an exception:  
ElasticsearchIllegalArgumentException[field [s3] isn't a leaf field]

Is this approach unsupported? Am I doing something wrong?  
A small example:

curl -XPOST localhost:9200/.test?pretty=true -d {'  
"mappings": {  
"test": {  
"\_source" : {"enabled" : false},  
"properties": {  
"s1": { "type": "integer", "index": "no", "store": "yes" },  
"s2": { "type": "integer", "index": "no", "store": "yes" },  
"s3": { "type": "object", "index": "no", "store": "yes" }  
}}  
}  
}'

curl -XPOST localhost:9200/.test/test/1 -d {'  
"s1": 123,  
"s2": [1,2,3,4,5],  
"s3": [{"x":1, "y":2, "z":3}]  
}'

sleep 1

#will succeed  
curl -XPOST localhost:9200/.test/\_search?pretty=true -d {'  
"fields": ["s1", "s2"]  
}'

#will fail with "ElasticsearchIllegalArgumentException[field [s3] isn't a  
leaf field]"  
curl -XPOST localhost:9200/.test/\_search?pretty=true -d {'  
"fields": ["s3"]  
}'

I am aware that I could use the \_source field and just exclude the body  
from it. But I expect that fetching the complete \_source is costly.  
I would like to measure the impact of the 2 solutions.

Thanks,  
Peter

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/525eb286-8a20-43cb-ba79-aab07e58b4a4%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/525eb286-8a20-43cb-ba79-aab07e58b4a4%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [November 11, 2014, 10:18pm UTC](https://discuss.elastic.co/t/disabling--source-and-using-stored-fields/20679/2 "2014-11-11T22:18:40Z")

</div>

Hi Peter,

Unfortunately elasticsearch does not support storing object fields (the  
fact that it did not fail the mapping update that you sent is due to the  
fact that parsing is lenient and ignores unknown parameters).

In your case, I think an option could be to keep \_source enabled, and to  
also store small meta fields on their own. Compression should make the  
overhead very minimal in terms of disk space. Then when you only need meta  
fields you can use the fields= option, and otherwise use source filtering  
when you need to fetch entire objects or unstored fields.

On Tue, Nov 11, 2014 at 7:27 AM, Peter van der Weerd [pw2@bitmanager.nl](mailto:pw2@bitmanager.nl)  
wrote:

> Hi,
> 
> I have a use case of very large documents (size\>10MB) where the metadata  
> (title, author, etc) is small.  
> I thought it could be beneficial to separate the body from the metadata  
> and use different fields for them, because in a result list, you typically  
> only need the metadata.  
> So, I disabled the \_source field and stored both the body as the metadata  
> as fields.
> 
> However, while storing and indexing works as expected, I'm not able to get  
> my data back.  
> Complex fields (ie objects) cannot be retrieved and return an exception:  
> ElasticsearchIllegalArgumentException[field [s3] isn't a leaf field]
> 
> Is this approach unsupported? Am I doing something wrong?  
> A small example:
> 
> curl -XPOST localhost:9200/.test?pretty=true -d {'  
> "mappings": {  
> "test": {  
> "\_source" : {"enabled" : false},  
> "properties": {  
> "s1": { "type": "integer", "index": "no", "store": "yes"  
> },  
> "s2": { "type": "integer", "index": "no", "store": "yes"  
> },  
> "s3": { "type": "object", "index": "no", "store": "yes" }  
> }}  
> }  
> }'
> 
> curl -XPOST localhost:9200/.test/test/1 -d {'  
> "s1": 123,  
> "s2": [1,2,3,4,5],  
> "s3": [{"x":1, "y":2, "z":3}]  
> }'
> 
> sleep 1
> 
> #will succeed  
> curl -XPOST localhost:9200/.test/\_search?pretty=true -d {'  
> "fields": ["s1", "s2"]  
> }'
> 
> #will fail with "ElasticsearchIllegalArgumentException[field [s3] isn't a  
> leaf field]"  
> curl -XPOST localhost:9200/.test/\_search?pretty=true -d {'  
> "fields": ["s3"]  
> }'
> 
> I am aware that I could use the \_source field and just exclude the body  
> from it. But I expect that fetching the complete \_source is costly.  
> I would like to measure the impact of the 2 solutions.
> 
> Thanks,  
> Peter
> 
> --  
> 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).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/525eb286-8a20-43cb-ba79-aab07e58b4a4%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/525eb286-8a20-43cb-ba79-aab07e58b4a4%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/525eb286-8a20-43cb-ba79-aab07e58b4a4%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/525eb286-8a20-43cb-ba79-aab07e58b4a4%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
Adrien Grand

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j4H6VdLaYFZOVTCDzAH%3DaKS6-NF\_zF%2B%3DDr%2B8e%3D%3D-Zsy%2BA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j4H6VdLaYFZOVTCDzAH%3DaKS6-NF_zF%2B%3DDr%2B8e%3D%3D-Zsy%2BA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:50am UTC](https://discuss.elastic.co/t/disabling--source-and-using-stored-fields/20679/3 "2017-07-06T00:50:40Z")

</div>


