# Query returning only ids

**URL:** <https://discuss.elastic.co/t/query-returning-only-ids/5135>\
**Category:** Elasticsearch\
**Created:** [August 12, 2011, 10:32am UTC](https://discuss.elastic.co/t/query-returning-only-ids/5135 "2011-08-12T10:32:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ridvan\_Gyundogan](https://avatars.discourse-cdn.com/v4/letter/r/e495f1/32.png) [@Ridvan\_Gyundogan](https://discuss.elastic.co/u/Ridvan_Gyundogan)\
**Post date:** [August 12, 2011, 10:32am UTC](https://discuss.elastic.co/t/query-returning-only-ids/5135/1 "2011-08-12T10:32:33Z")

</div>

Hello All, I am trying to run a query which returns only the id's for  
a given index without the source but I am unable to do it.

I try with a query like this:

{  
"fields": [  
"price",  
"\_id"  
],  
"\_source": {  
"enabled": false  
},  
"query": {  
"match\_all": {}  
}  
}

I know that I can disable the source field generally but we need it  
for other queries.

---

<div class="post-metadata">

**Author:** ![Jurgen\_kartnaller](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jurgen_kartnaller/32/3086_2.png) [@Jurgen\_kartnaller](https://discuss.elastic.co/u/Jurgen_kartnaller)\
**Post date:** [August 12, 2011, 12:26pm UTC](https://discuss.elastic.co/t/query-returning-only-ids/5135/2 "2011-08-12T12:26:59Z")

</div>

Just use fields=

On Fri, Aug 12, 2011 at 12:32 PM, Ridvan Gyundogan [ridvansg@gmail.com](mailto:ridvansg@gmail.com)wrote:

> Hello All, I am trying to run a query which returns only the id's for  
> a given index without the source but I am unable to do it.
> 
> I try with a query like this:
> 
> {  
> "fields": [  
> "price",  
> "\_id"  
> ],  
> "\_source": {  
> "enabled": false  
> },  
> "query": {  
> "match\_all": {}  
> }  
> }
> 
> I know that I can disable the source field generally but we need it  
> for other queries.

--  
[http://www.sfgdornbirn.at](http://www.sfgdornbirn.at)  
[http://www.mcb-bregenz.at](http://www.mcb-bregenz.at)

---

<div class="post-metadata">

**Author:** ![roger\_2](https://avatars.discourse-cdn.com/v4/letter/r/919ad9/32.png) [@roger\_2](https://discuss.elastic.co/u/roger_2)\
**Post date:** [August 12, 2011, 12:33pm UTC](https://discuss.elastic.co/t/query-returning-only-ids/5135/3 "2011-08-12T12:33:38Z")

</div>

Hi Jürgen

It's a long time ago, but nice to meet you here again!

Let me know if you need an elasticsearch stub server setup  
for python unit testing!

Regards  
Roger Ineichen

> -----Ursprüngliche Nachricht-----  
> Von: [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com)  
> [[mailto:elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com)] Im  
> Auftrag von Jürgen kartnaller  
> Gesendet: Freitag, 12. August 2011 14:27  
> An: [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com)  
> Betreff: Re: Query returning only ids
> 
> Just use fields=
> 
> On Fri, Aug 12, 2011 at 12:32 PM, Ridvan Gyundogan [ridvansg@gmail.com](mailto:ridvansg@gmail.com)  
> wrote:
> 
> Hello All, I am trying to run a query which returns only the id's  
> for  
> a given index without the source but I am unable to do it.
> 
> I try with a query like this:
> 
> {  
> "fields": [  
> "price",  
> "\_id"  
> ],  
> "\_source": {  
> "enabled": false  
> },  
> "query": {  
> "match\_all": {}  
> }  
> }
> 
> I know that I can disable the source field generally but we need it  
> for other queries.
> 
> --  
> [http://www.sfgdornbirn.at](http://www.sfgdornbirn.at)  
> [http://www.mcb-bregenz.at](http://www.mcb-bregenz.at)

---

<div class="post-metadata">

**Author:** ![Ridvan\_Gyundogan](https://avatars.discourse-cdn.com/v4/letter/r/e495f1/32.png) [@Ridvan\_Gyundogan](https://discuss.elastic.co/u/Ridvan_Gyundogan)\
**Post date:** [August 12, 2011, 12:54pm UTC](https://discuss.elastic.co/t/query-returning-only-ids/5135/4 "2011-08-12T12:54:51Z")

</div>

Thanks Jürgen,  
I actually tried fields but was putting it inside the query, the  
following worked:

curl -XGET [http://localhost:9200/giftsplusindex/giftsplusproduct/\_search?pretty=true](http://localhost:9200/giftsplusindex/giftsplusproduct/_search?pretty=true)  
-d '{  
"fields" : ["id", "price"],  
"query" : {  
"match\_all": {}  
}  
}'

On Aug 12, 3:33 pm, "Roger" [d...@projekt01.ch](mailto:d...@projekt01.ch) wrote:

> Hi Jürgen
> 
> It's a long time ago, but nice to meet you here again!
> 
> Let me know if you need an elasticsearch stub server setup  
> for python unit testing!
> 
> Regards  
> Roger Ineichen
> 
> > -----Ursprüngliche Nachricht-----  
> > Von: [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com)
> 
> [[mailto:elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com)] Im
> 
> > Auftrag von Jürgen kartnaller  
> > Gesendet: Freitag, 12. August 2011 14:27  
> > An: [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com)  
> > Betreff: Re: Query returning only ids
> 
> > Just use fields=
> 
> > On Fri, Aug 12, 2011 at 12:32 PM, Ridvan Gyundogan [ridva...@gmail.com](mailto:ridva...@gmail.com)  
> > wrote:
> 
> > Hello All, I am trying to run a query which returns only the id's  
> > for  
> > a given index without the source but I am unable to do it.
> 
> > I try with a query like this:
> 
> > {  
> > "fields": [  
> > "price",  
> > "\_id"  
> > ],  
> > "\_source": {  
> > "enabled": false  
> > },  
> > "query": {  
> > "match\_all": {}  
> > }  
> > }
> 
> > I know that I can disable the source field generally but we need it  
> > for other queries.
> 
> > --  
> > [http://www.sfgdornbirn.at](http://www.sfgdornbirn.at)  
> > [http://www.mcb-bregenz.at](http://www.mcb-bregenz.at)

---

<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:57am UTC](https://discuss.elastic.co/t/query-returning-only-ids/5135/5 "2017-07-06T03:57:20Z")

</div>


