# Get returns source even though source is disabled

**URL:** <https://discuss.elastic.co/t/get-returns-source-even-though-source-is-disabled/5486>\
**Category:** Elasticsearch\
**Created:** [September 30, 2011, 9:43am UTC](https://discuss.elastic.co/t/get-returns-source-even-though-source-is-disabled/5486 "2011-09-30T09:43:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ruflin\_2](https://avatars.discourse-cdn.com/v4/letter/r/a8b319/32.png) [@ruflin\_2](https://discuss.elastic.co/u/ruflin_2)\
**Post date:** [September 30, 2011, 9:43am UTC](https://discuss.elastic.co/t/get-returns-source-even-though-source-is-disabled/5486/1 "2011-09-30T09:43:08Z")

</div>

During writing tests for Elastica I received a result that I was not  
expecting. I create a index and set the mapping to not store the source, but  
I set store to yes on one field. Then, when I query I can received the  
stored field and no source is returned (as expected). But when I explicitly  
get the document, the source is returned. I would expect that it says, field  
exists but that id does not return the source. I created a gist with an  
example:

> <https://gist.github.com/ruflin/1253270>

---

<div class="post-metadata">

**Author:** ![Benjamin\_Deveze](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benjamin_deveze/32/1577_2.png) [@Benjamin\_Deveze](https://discuss.elastic.co/u/Benjamin_Deveze)\
**Post date:** [September 30, 2011, 9:55am UTC](https://discuss.elastic.co/t/get-returns-source-even-though-source-is-disabled/5486/2 "2011-09-30T09:55:59Z")

</div>

I guess it is because this call:  
curl -XGET '[http://localhost:9200/test/test/1?pretty=true](http://localhost:9200/test/test/1?pretty=true)  
fetch the document from the transaction log and so it gets the \_source  
there.

But if you flush using curl -XPOST '[http://localhost:9200/test/\_flush](http://localhost:9200/test/_flush)'

Then you have the behavior you expect.

---

<div class="post-metadata">

**Author:** ![Nicolas\_Ruflin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nicolas_ruflin/32/3116_2.png) [@Nicolas\_Ruflin](https://discuss.elastic.co/u/Nicolas_Ruflin)\
**Post date:** [September 30, 2011, 1:42pm UTC](https://discuss.elastic.co/t/get-returns-source-even-though-source-is-disabled/5486/3 "2011-09-30T13:42:22Z")

</div>

## Thx, this solved the problem. And probably also explains an other problem I sometimes have.

@ruflin  
[useKit.com](http://useKit.com)

> **[Xodoa](https://www.xodoa.com/)**

> **[Blog by Nicolas Ruflin](https://www.ruflin.com/)**
>
> Blog by Nicolas Ruflin

On 30.09.2011, at 11:55, Benjamin Devèze wrote:

> I guess it is because this call:  
> curl -XGET '[http://localhost:9200/test/test/1?pretty=true](http://localhost:9200/test/test/1?pretty=true)  
> fetch the document from the transaction log and so it gets the \_source there.
> 
> But if you flush using curl -XPOST '[http://localhost:9200/test/\_flush](http://localhost:9200/test/_flush)'
> 
> Then you have the behavior you expect.

---

<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 2, 2011, 10:50am UTC](https://discuss.elastic.co/t/get-returns-source-even-though-source-is-disabled/5486/4 "2011-10-02T10:50:37Z")

</div>

This happens because of how realtime gets works. Basically, realtime get  
works from the \_source, and when you ask for a field which is stored, it  
will try and parse the source and return it if its a realtime get. You can  
always set realtime flag set to false on the GET operation, and disable this  
behavior (btw).

On Fri, Sep 30, 2011 at 4:42 PM, Nicolas Ruflin [mail@ruflin.com](mailto:mail@ruflin.com) wrote:

> ## Thx, this solved the problem. And probably also explains an other problem I sometimes have.
> 
> @ [http://twitter.com/ruflin](http://twitter.com/ruflin)ruflin [http://twitter.com/ruflin](http://twitter.com/ruflin)  
> [useKit.com](http://useKit.com)  
> [Xodoa.com](http://Xodoa.com) [http://xodoa.com/](http://xodoa.com/)  
> [Ruflin.com](http://Ruflin.com) [http://ruflin.com](http://ruflin.com)
> 
> On 30.09.2011, at 11:55, Benjamin Devèze wrote:
> 
> I guess it is because this call:  
> curl -XGET '[http://localhost:9200/test/test/1?pretty=true](http://localhost:9200/test/test/1?pretty=true)  
> fetch the document from the transaction log and so it gets the \_source  
> there.
> 
> But if you flush using curl -XPOST '[http://localhost:9200/test/\_flush](http://localhost:9200/test/_flush)'
> 
> Then you have the behavior you expect.

---

<div class="post-metadata">

**Author:** ![Nicolas\_Ruflin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nicolas_ruflin/32/3116_2.png) [@Nicolas\_Ruflin](https://discuss.elastic.co/u/Nicolas_Ruflin)\
**Post date:** [October 2, 2011, 3:44pm UTC](https://discuss.elastic.co/t/get-returns-source-even-though-source-is-disabled/5486/5 "2011-10-02T15:44:59Z")

</div>

## Thx for the explanation. In general I really like the realtime get. It was just a "testing" issue.

@ruflin  
[useKit.com](http://useKit.com)

> **[Xodoa](https://www.xodoa.com/)**

> **[Blog by Nicolas Ruflin](https://www.ruflin.com/)**
>
> Blog by Nicolas Ruflin

On 02.10.2011, at 12:50, Shay Banon wrote:

> This happens because of how realtime gets works. Basically, realtime get works from the \_source, and when you ask for a field which is stored, it will try and parse the source and return it if its a realtime get. You can always set realtime flag set to false on the GET operation, and disable this behavior (btw).
> 
> ## On Fri, Sep 30, 2011 at 4:42 PM, Nicolas Ruflin [mail@ruflin.com](mailto:mail@ruflin.com) wrote: Thx, this solved the problem. And probably also explains an other problem I sometimes have.
> 
> @ruflin  
> [useKit.com](http://useKit.com)  
> [Xodoa.com](http://Xodoa.com)  
> [Ruflin.com](http://Ruflin.com)
> 
> On 30.09.2011, at 11:55, Benjamin Devèze wrote:
> 
> > I guess it is because this call:  
> > curl -XGET '[http://localhost:9200/test/test/1?pretty=true](http://localhost:9200/test/test/1?pretty=true)  
> > fetch the document from the transaction log and so it gets the \_source there.
> > 
> > But if you flush using curl -XPOST '[http://localhost:9200/test/\_flush](http://localhost:9200/test/_flush)'
> > 
> > Then you have the behavior you expect.

---

<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, 3:53am UTC](https://discuss.elastic.co/t/get-returns-source-even-though-source-is-disabled/5486/6 "2017-07-06T03:53:04Z")

</div>


