# Stored fields

**URL:** <https://discuss.elastic.co/t/stored-fields/3486>\
**Category:** Elasticsearch\
**Created:** [October 28, 2010, 3:24pm UTC](https://discuss.elastic.co/t/stored-fields/3486 "2010-10-28T15:24:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Albin\_Stigo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/albin_stigo/32/3227_2.png) [@Albin\_Stigo](https://discuss.elastic.co/u/Albin_Stigo)\
**Post date:** [October 28, 2010, 3:24pm UTC](https://discuss.elastic.co/t/stored-fields/3486/1 "2010-10-28T15:24:04Z")

</div>

Hi,

If this is a stupid question, please excuse me, I'm new in search.

What is the main advantage of stored fields... I know that they can be  
selectively loaded but can they not just be selectively loaded from  
the \_source field instead?

--Albin

On Thu, Oct 28, 2010 at 12:05 PM, Shay Banon  
[shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com) wrote:

> Hi,  
> Just pushed support ip address support (with auto  
> detection): [Mapper: Ip Type Support (ipv4), auto detection with dynamic mapping · Issue #461 · elastic/elasticsearch · GitHub](http://github.com/elasticsearch/elasticsearch/issues/issue/461)  
> (as discussed in a previous) thread.  
> Here is a simple test I do to have the previous mentioned question  
> (yea.., in java):
> 
> ```
> client.prepareIndex("test", "type1", "1").setSource("from",
> 
> ```
> 
> "192.168.0.5", "to", "192.168.0.10").setRefresh(true).execute().actionGet();  
> SearchResponse search = client.prepareSearch()
> 
> .setQuery(boolQuery().must(rangeQuery("from").lt("192.168.0.7")).must(rangeQuery("to").gt("192.168.0.7")))  
> .execute().actionGet();
> 
> -shay.banon

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [October 28, 2010, 5:49pm UTC](https://discuss.elastic.co/t/stored-fields/3486/2 "2010-10-28T17:49:45Z")

</div>

Hi,

They can be selectively loaded from the \_source field, either by  
specifying a notation to load them (\_source.obj1.field1) or getting the full  
\_source and using them on the client side.

Returning the full \_source field means loading it from disk and returning  
it. For large docs this might not be an option. Note that compression can  
really help in this option (it "travels" compressed right up to the client /  
REST layer).

Getting it using the \_source notion means loading the \_source on the  
relevant shard, parsing it, and returning the relevant data.

Storing fields means that only those fields can be loaded from disk. The  
benefit is that you load less data, at the expense of storing more data. One  
important thing to note is that if you choose to load several fields, it  
might be slower than loading a single \_source field, even if the \_source  
field is bigger than the total size of the fields loaded.

Hope it make sense.

-shay.banon

On Thu, Oct 28, 2010 at 5:24 PM, Albin Stigo [albin.stigo@gmail.com](mailto:albin.stigo@gmail.com) wrote:

> Hi,
> 
> If this is a stupid question, please excuse me, I'm new in search.
> 
> What is the main advantage of stored fields... I know that they can be  
> selectively loaded but can they not just be selectively loaded from  
> the \_source field instead?
> 
> --Albin
> 
> On Thu, Oct 28, 2010 at 12:05 PM, Shay Banon  
> [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com) wrote:
> 
> > Hi,  
> > Just pushed support ip address support (with auto  
> > detection):  
> > [Mapper: Ip Type Support (ipv4), auto detection with dynamic mapping · Issue #461 · elastic/elasticsearch · GitHub](http://github.com/elasticsearch/elasticsearch/issues/issue/461)  
> > (as discussed in a previous) thread.  
> > Here is a simple test I do to have the previous mentioned question  
> > (yea.., in java):
> > 
> > ```
> > client.prepareIndex("test", "type1", "1").setSource("from",
> > 
> > ```
> > 
> > "192.168.0.5", "to",  
> > "192.168.0.10").setRefresh(true).execute().actionGet();  
> > SearchResponse search = client.prepareSearch()
> 
> .setQuery(boolQuery().must(rangeQuery("from").lt("192.168.0.7")).must(rangeQuery("to").gt("192.168.0.7")))
> 
> > ```
> > .execute().actionGet();
> > 
> > ```
> > 
> > -shay.banon

---

<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, 4:17am UTC](https://discuss.elastic.co/t/stored-fields/3486/3 "2017-07-06T04:17:28Z")

</div>


