# Fetching both \_source and a specific field in scan search

**URL:** <https://discuss.elastic.co/t/fetching-both--source-and-a-specific-field-in-scan-search/7474>\
**Category:** Elasticsearch\
**Created:** [April 26, 2012, 1:13pm UTC](https://discuss.elastic.co/t/fetching-both--source-and-a-specific-field-in-scan-search/7474 "2012-04-26T13:13:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeremie\_BORDIER1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jeremie_bordier1/32/2860_2.png) [@Jeremie\_BORDIER1](https://discuss.elastic.co/u/Jeremie_BORDIER1)\
**Post date:** [April 26, 2012, 1:13pm UTC](https://discuss.elastic.co/t/fetching-both--source-and-a-specific-field-in-scan-search/7474/1 "2012-04-26T13:13:36Z")

</div>

Hi,

I'm trying to fetch both the \_source field and another field that is  
excluded from source, but I can't get elasticsearch to return me both  
of these:

SearchResponse scrollResp = client.prepareSearch("test")  
.setSearchType(SearchType.SCAN)  
.setScroll(new TimeValue(60000))  
.setSize(100).execute().actionGet(); //100 hits per shard will be  
returned for each scroll

=\> Will return source (hit.source() is filled)

```
	.addFields("file")

```

=\> Will only return "file"

```
	.addFields("_source", "file")

```

=\> Will only return "file"...

Any hint ?

Thanks !

Jérémie

---

<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:** [April 26, 2012, 9:15pm UTC](https://discuss.elastic.co/t/fetching-both--source-and-a-specific-field-in-scan-search/7474/2 "2012-04-26T21:15:14Z")

</div>

Which version are you using? Something similar was fixed in 0.19.2:  
[requesting fields=\_timestamp,\_source won't return \_source · Issue #1833 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1833).

On Thu, Apr 26, 2012 at 4:13 PM, Jérémie BORDIER  
[jeremie.bordier@gmail.com](mailto:jeremie.bordier@gmail.com)wrote:

> Hi,
> 
> I'm trying to fetch both the \_source field and another field that is  
> excluded from source, but I can't get elasticsearch to return me both  
> of these:
> 
> SearchResponse scrollResp = client.prepareSearch("test")  
> .setSearchType(SearchType.SCAN)  
> .setScroll(new TimeValue(60000))  
> .setSize(100).execute().actionGet(); //100 hits per shard  
> will be  
> returned for each scroll
> 
> =\> Will return source (hit.source() is filled)
> 
> ```
> .addFields("file")
> 
> ```
> 
> =\> Will only return "file"
> 
> ```
> .addFields("_source", "file")
> 
> ```
> 
> =\> Will only return "file"...
> 
> Any hint ?
> 
> Thanks !
> 
> Jérémie

---

<div class="post-metadata">

**Author:** ![Jeremie\_BORDIER1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jeremie_bordier1/32/2860_2.png) [@Jeremie\_BORDIER1](https://discuss.elastic.co/u/Jeremie_BORDIER1)\
**Post date:** [April 27, 2012, 9:13am UTC](https://discuss.elastic.co/t/fetching-both--source-and-a-specific-field-in-scan-search/7474/3 "2012-04-27T09:13:35Z")

</div>

I'm on 0.19.1, I'll give 0.19.2 a shot 🙂 Thanks

Jérémie

On Thu, Apr 26, 2012 at 11:15 PM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:

> Which version are you using? Something similar was fixed in  
> 0.19.2: [requesting fields=\_timestamp,\_source won't return \_source · Issue #1833 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1833).
> 
> On Thu, Apr 26, 2012 at 4:13 PM, Jérémie BORDIER [jeremie.bordier@gmail.com](mailto:jeremie.bordier@gmail.com)  
> wrote:
> 
> > Hi,
> > 
> > I'm trying to fetch both the \_source field and another field that is  
> > excluded from source, but I can't get elasticsearch to return me both  
> > of these:
> > 
> > SearchResponse scrollResp = client.prepareSearch("test")  
> > .setSearchType(SearchType.SCAN)  
> > .setScroll(new TimeValue(60000))  
> > .setSize(100).execute().actionGet(); //100 hits per shard  
> > will be  
> > returned for each scroll
> > 
> > =\> Will return source (hit.source() is filled)
> > 
> > ```
> > .addFields("file")
> > 
> > ```
> > 
> > =\> Will only return "file"
> > 
> > ```
> > .addFields("_source", "file")
> > 
> > ```
> > 
> > =\> Will only return "file"...
> > 
> > Any hint ?
> > 
> > Thanks !
> > 
> > Jérémie

--  
Jérémie 'ahFeel' BORDIER

---

<div class="post-metadata">

**Author:** ![Jeremie\_BORDIER1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jeremie_bordier1/32/2860_2.png) [@Jeremie\_BORDIER1](https://discuss.elastic.co/u/Jeremie_BORDIER1)\
**Post date:** [April 27, 2012, 9:19am UTC](https://discuss.elastic.co/t/fetching-both--source-and-a-specific-field-in-scan-search/7474/4 "2012-04-27T09:19:06Z")

</div>

Works ! Thanks 🙂

Jérémie

On Fri, Apr 27, 2012 at 11:13 AM, Jérémie BORDIER  
[jeremie.bordier@gmail.com](mailto:jeremie.bordier@gmail.com) wrote:

> I'm on 0.19.1, I'll give 0.19.2 a shot 🙂 Thanks
> 
> Jérémie
> 
> On Thu, Apr 26, 2012 at 11:15 PM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:
> 
> > Which version are you using? Something similar was fixed in  
> > 0.19.2: [requesting fields=\_timestamp,\_source won't return \_source · Issue #1833 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1833).
> > 
> > On Thu, Apr 26, 2012 at 4:13 PM, Jérémie BORDIER [jeremie.bordier@gmail.com](mailto:jeremie.bordier@gmail.com)  
> > wrote:
> > 
> > > Hi,
> > > 
> > > I'm trying to fetch both the \_source field and another field that is  
> > > excluded from source, but I can't get elasticsearch to return me both  
> > > of these:
> > > 
> > > SearchResponse scrollResp = client.prepareSearch("test")  
> > > .setSearchType(SearchType.SCAN)  
> > > .setScroll(new TimeValue(60000))  
> > > .setSize(100).execute().actionGet(); //100 hits per shard  
> > > will be  
> > > returned for each scroll
> > > 
> > > =\> Will return source (hit.source() is filled)
> > > 
> > > ```
> > > .addFields("file")
> > > 
> > > ```
> > > 
> > > =\> Will only return "file"
> > > 
> > > ```
> > > .addFields("_source", "file")
> > > 
> > > ```
> > > 
> > > =\> Will only return "file"...
> > > 
> > > Any hint ?
> > > 
> > > Thanks !
> > > 
> > > Jérémie
> 
> --  
> Jérémie 'ahFeel' BORDIER

--  
Jérémie 'ahFeel' BORDIER

---

<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:30am UTC](https://discuss.elastic.co/t/fetching-both--source-and-a-specific-field-in-scan-search/7474/5 "2017-07-06T03:30:55Z")

</div>


