# Can I find a list of indices containing documents which contain a specified term?

**URL:** <https://discuss.elastic.co/t/can-i-find-a-list-of-indices-containing-documents-which-contain-a-specified-term/19547>\
**Category:** Elasticsearch\
**Created:** [September 1, 2014, 9:40am UTC](https://discuss.elastic.co/t/can-i-find-a-list-of-indices-containing-documents-which-contain-a-specified-term/19547 "2014-09-01T09:40:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris\_Lees](https://avatars.discourse-cdn.com/v4/letter/c/278dde/32.png) [@Chris\_Lees](https://discuss.elastic.co/u/Chris_Lees)\
**Post date:** [September 1, 2014, 9:40am UTC](https://discuss.elastic.co/t/can-i-find-a-list-of-indices-containing-documents-which-contain-a-specified-term/19547/1 "2014-09-01T09:40:33Z")

</div>

I'm building a simple app which presents the user with two drop-downs to  
easily filter data: one for day (mapping to my daily indices), and one for  
client (a term within documents).

I'm currently finding indices using curl -XGET localhost:9200/\_aliases, and  
a simple aggregation query to get a list of known clients over all indices.  
It works, but since not every client is present on every date it feels  
clunky when the client is known but the list of dates still contains all  
indices, many of which are irrelevant for the selected client.

Can anyone recommend a good way of finding a list of indices in which there  
is at least one document containing a specified term please? Thank you very  
much.

--  
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/3dcf46da-3eeb-4503-a348-365e3f0fd7a0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3dcf46da-3eeb-4503-a348-365e3f0fd7a0%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![vineeth\_mohan\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vineeth_mohan_2/32/747_2.png) [@vineeth\_mohan\_2](https://discuss.elastic.co/u/vineeth_mohan_2)\
**Post date:** [September 1, 2014, 12:39pm UTC](https://discuss.elastic.co/t/can-i-find-a-list-of-indices-containing-documents-which-contain-a-specified-term/19547/2 "2014-09-01T12:39:53Z")

</div>

Hello Chris ,

This should work -

{  
"query" : {  
// GIVE QUERY HERE  
},  
"aggregations": {  
"aggs": {  
"terms": {  
"field": "\_index"  
}  
}  
}  
}

Thanks  
Vineeth

On Mon, Sep 1, 2014 at 3:10 PM, Chris Lees [chris@fixspec.com](mailto:chris@fixspec.com) wrote:

> I'm building a simple app which presents the user with two drop-downs to  
> easily filter data: one for day (mapping to my daily indices), and one for  
> client (a term within documents).
> 
> I'm currently finding indices using curl -XGET localhost:9200/\_aliases,  
> and a simple aggregation query to get a list of known clients over all  
> indices. It works, but since not every client is present on every date it  
> feels clunky when the client is known but the list of dates still contains  
> all indices, many of which are irrelevant for the selected client.
> 
> Can anyone recommend a good way of finding a list of indices in which  
> there is at least one document containing a specified term please? Thank  
> you very much.
> 
> --  
> 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/3dcf46da-3eeb-4503-a348-365e3f0fd7a0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3dcf46da-3eeb-4503-a348-365e3f0fd7a0%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/3dcf46da-3eeb-4503-a348-365e3f0fd7a0%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/3dcf46da-3eeb-4503-a348-365e3f0fd7a0%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/CAGdPd5kdfq2kuroxFVx2590k03SQf7T\_H0PhrCGeA1\_OoKMDxQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGdPd5kdfq2kuroxFVx2590k03SQf7T_H0PhrCGeA1_OoKMDxQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Chris\_Lees](https://avatars.discourse-cdn.com/v4/letter/c/278dde/32.png) [@Chris\_Lees](https://discuss.elastic.co/u/Chris_Lees)\
**Post date:** [September 1, 2014, 12:47pm UTC](https://discuss.elastic.co/t/can-i-find-a-list-of-indices-containing-documents-which-contain-a-specified-term/19547/3 "2014-09-01T12:47:31Z")

</div>

Thanks Vineeth.

Unfortunately it doesn't return any results in the aggregations result.

Input query:  
GET \_search  
{  
"aggregations": {  
"aggs": {  
"terms": {  
"field": "\_index"  
}  
}  
}  
}

Result JSON showing 26K hits (correct), but no index aggregations:  
{  
"took": 4,  
"timed\_out": false,  
"\_shards": {  
"total": 57,  
"successful": 57,  
"failed": 0  
},  
"hits": {  
"total": 26622,  
"max\_score": 1,  
"hits": [...]  
},  
"aggregations": {  
"aggs": {  
"buckets":   
}  
}  
}

On Monday, September 1, 2014 1:40:00 PM UTC+1, vineeth mohan wrote:

> Hello Chris ,
> 
> This should work -
> 
> {  
> "query" : {  
> // GIVE QUERY HERE  
> },  
> "aggregations": {  
> "aggs": {  
> "terms": {  
> "field": "\_index"  
> }  
> }  
> }  
> }
> 
> Thanks  
> Vineeth
> 
> On Mon, Sep 1, 2014 at 3:10 PM, Chris Lees \<[ch...@fixspec.com](mailto:ch...@fixspec.com)  
> \<javascript:\>\> wrote:
> 
> > I'm building a simple app which presents the user with two drop-downs to  
> > easily filter data: one for day (mapping to my daily indices), and one for  
> > client (a term within documents).
> > 
> > I'm currently finding indices using curl -XGET localhost:9200/\_aliases,  
> > and a simple aggregation query to get a list of known clients over all  
> > indices. It works, but since not every client is present on every date it  
> > feels clunky when the client is known but the list of dates still contains  
> > all indices, many of which are irrelevant for the selected client.
> > 
> > Can anyone recommend a good way of finding a list of indices in which  
> > there is at least one document containing a specified term please? Thank  
> > you very much.
> > 
> > --  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/3dcf46da-3eeb-4503-a348-365e3f0fd7a0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3dcf46da-3eeb-4503-a348-365e3f0fd7a0%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/3dcf46da-3eeb-4503-a348-365e3f0fd7a0%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/3dcf46da-3eeb-4503-a348-365e3f0fd7a0%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/a485bf59-4ab6-43a3-b3df-172b8d09e7ba%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a485bf59-4ab6-43a3-b3df-172b8d09e7ba%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![vineeth\_mohan\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vineeth_mohan_2/32/747_2.png) [@vineeth\_mohan\_2](https://discuss.elastic.co/u/vineeth_mohan_2)\
**Post date:** [September 1, 2014, 1:23pm UTC](https://discuss.elastic.co/t/can-i-find-a-list-of-indices-containing-documents-which-contain-a-specified-term/19547/4 "2014-09-01T13:23:11Z")

</div>

Hello Chris ,

That is strange , its working fine on my side.

Can you run the below and paste the result -

curl -XPOST '[http://localhost:9200/\_search](http://localhost:9200/_search)' -d '{  
"aggregations": {  
"aggs": {  
"terms": {  
"field": "\_index"  
}  
}  
}  
}'  
Thanks  
Vineeth

On Mon, Sep 1, 2014 at 6:17 PM, Chris Lees [chris@fixspec.com](mailto:chris@fixspec.com) wrote:

> Thanks Vineeth.
> 
> Unfortunately it doesn't return any results in the aggregations result.
> 
> Input query:  
> GET \_search
> 
> {  
> "aggregations": {  
> "aggs": {  
> "terms": {  
> "field": "\_index"  
> }  
> }  
> }  
> }
> 
> Result JSON showing 26K hits (correct), but no index aggregations:  
> {  
> "took": 4,  
> "timed\_out": false,  
> "\_shards": {  
> "total": 57,  
> "successful": 57,  
> "failed": 0  
> },  
> "hits": {  
> "total": 26622,  
> "max\_score": 1,  
> "hits": [...]  
> },  
> "aggregations": {  
> "aggs": {  
> "buckets":
> 
> ```
> }
> 
> ```
> 
> }  
> }
> 
> On Monday, September 1, 2014 1:40:00 PM UTC+1, vineeth mohan wrote:
> 
> > Hello Chris ,
> > 
> > This should work -
> > 
> > {  
> > "query" : {  
> > // GIVE QUERY HERE  
> > },  
> > "aggregations": {  
> > "aggs": {  
> > "terms": {  
> > "field": "\_index"  
> > }  
> > }  
> > }  
> > }
> > 
> > Thanks  
> > Vineeth
> > 
> > On Mon, Sep 1, 2014 at 3:10 PM, Chris Lees [ch...@fixspec.com](mailto:ch...@fixspec.com) wrote:
> > 
> > > I'm building a simple app which presents the user with two drop-downs to  
> > > easily filter data: one for day (mapping to my daily indices), and one for  
> > > client (a term within documents).
> > > 
> > > I'm currently finding indices using curl -XGET localhost:9200/\_aliases,  
> > > and a simple aggregation query to get a list of known clients over all  
> > > indices. It works, but since not every client is present on every date it  
> > > feels clunky when the client is known but the list of dates still contains  
> > > all indices, many of which are irrelevant for the selected client.
> > > 
> > > Can anyone recommend a good way of finding a list of indices in which  
> > > there is at least one document containing a specified term please? Thank  
> > > you very much.
> > > 
> > > --  
> > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).
> > > 
> > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > msgid/elasticsearch/3dcf46da-3eeb-4503-a348-365e3f0fd7a0%  
> > > [40googlegroups.com](http://40googlegroups.com)  
> > > [https://groups.google.com/d/msgid/elasticsearch/3dcf46da-3eeb-4503-a348-365e3f0fd7a0%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/3dcf46da-3eeb-4503-a348-365e3f0fd7a0%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .  
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > 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/a485bf59-4ab6-43a3-b3df-172b8d09e7ba%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a485bf59-4ab6-43a3-b3df-172b8d09e7ba%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/a485bf59-4ab6-43a3-b3df-172b8d09e7ba%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/a485bf59-4ab6-43a3-b3df-172b8d09e7ba%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/CAGdPd5%3DNtGZhQRDkX90p39KxpRNeekbWSq5gasyaVK%3DevUHe\_g%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGdPd5%3DNtGZhQRDkX90p39KxpRNeekbWSq5gasyaVK%3DevUHe_g%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Chris\_Lees](https://avatars.discourse-cdn.com/v4/letter/c/278dde/32.png) [@Chris\_Lees](https://discuss.elastic.co/u/Chris_Lees)\
**Post date:** [September 1, 2014, 1:29pm UTC](https://discuss.elastic.co/t/can-i-find-a-list-of-indices-containing-documents-which-contain-a-specified-term/19547/5 "2014-09-01T13:29:04Z")

</div>

Same result I'm afraid...

{  
"took": 62,  
"timed\_out": false,  
"\_shards": {  
"total": 147,  
"successful": 144,  
"failed": 0  
},  
"hits": {  
"total": 9975671,  
"max\_score": 1.0,  
"hits": [  
... results removed as data is sensitive, but I see correct  
documents returned in here ...  
]  
},  
"aggregations": {  
"aggs": {  
"buckets":   
}  
}  
}

I'm still running Elasticsearch 1.1.1 -- is this something that changed  
after that perhaps?

Thanks for your help.

On Monday, September 1, 2014 2:23:17 PM UTC+1, vineeth mohan wrote:

> Hello Chris ,
> 
> That is strange , its working fine on my side.
> 
> Can you run the below and paste the result -
> 
> curl -XPOST '[http://localhost:9200/\_search](http://localhost:9200/_search)' -d '{  
> "aggregations": {  
> "aggs": {  
> "terms": {  
> "field": "\_index"  
> }  
> }  
> }  
> }'  
> Thanks  
> Vineeth
> 
> On Mon, Sep 1, 2014 at 6:17 PM, Chris Lees \<[ch...@fixspec.com](mailto:ch...@fixspec.com)  
> \<javascript:\>\> wrote:
> 
> > Thanks Vineeth.
> > 
> > Unfortunately it doesn't return any results in the aggregations result.
> > 
> > Input query:  
> > GET \_search
> > 
> > {  
> > "aggregations": {  
> > "aggs": {  
> > "terms": {  
> > "field": "\_index"  
> > }  
> > }  
> > }  
> > }
> > 
> > Result JSON showing 26K hits (correct), but no index aggregations:  
> > {  
> > "took": 4,  
> > "timed\_out": false,  
> > "\_shards": {  
> > "total": 57,  
> > "successful": 57,  
> > "failed": 0  
> > },  
> > "hits": {  
> > "total": 26622,  
> > "max\_score": 1,  
> > "hits": [...]  
> > },  
> > "aggregations": {  
> > "aggs": {  
> > "buckets":
> > 
> > ```
> > }
> > 
> > ```
> > 
> > }  
> > }
> > 
> > On Monday, September 1, 2014 1:40:00 PM UTC+1, vineeth mohan wrote:
> > 
> > > Hello Chris ,
> > > 
> > > This should work -
> > > 
> > > {  
> > > "query" : {  
> > > // GIVE QUERY HERE  
> > > },  
> > > "aggregations": {  
> > > "aggs": {  
> > > "terms": {  
> > > "field": "\_index"  
> > > }  
> > > }  
> > > }  
> > > }
> > > 
> > > Thanks  
> > > Vineeth
> > > 
> > > On Mon, Sep 1, 2014 at 3:10 PM, Chris Lees [ch...@fixspec.com](mailto:ch...@fixspec.com) wrote:
> > > 
> > > > I'm building a simple app which presents the user with two drop-downs  
> > > > to easily filter data: one for day (mapping to my daily indices), and one  
> > > > for client (a term within documents).
> > > > 
> > > > I'm currently finding indices using curl -XGET localhost:9200/\_aliases,  
> > > > and a simple aggregation query to get a list of known clients over all  
> > > > indices. It works, but since not every client is present on every date it  
> > > > feels clunky when the client is known but the list of dates still contains  
> > > > all indices, many of which are irrelevant for the selected client.
> > > > 
> > > > Can anyone recommend a good way of finding a list of indices in which  
> > > > there is at least one document containing a specified term please? Thank  
> > > > you very much.
> > > > 
> > > > --  
> > > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).
> > > > 
> > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > msgid/elasticsearch/3dcf46da-3eeb-4503-a348-365e3f0fd7a0%  
> > > > [40googlegroups.com](http://40googlegroups.com)  
> > > > [https://groups.google.com/d/msgid/elasticsearch/3dcf46da-3eeb-4503-a348-365e3f0fd7a0%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/3dcf46da-3eeb-4503-a348-365e3f0fd7a0%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > .  
> > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > 
> > > --  
> > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/a485bf59-4ab6-43a3-b3df-172b8d09e7ba%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a485bf59-4ab6-43a3-b3df-172b8d09e7ba%40googlegroups.com)  
> > > [https://groups.google.com/d/msgid/elasticsearch/a485bf59-4ab6-43a3-b3df-172b8d09e7ba%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/a485bf59-4ab6-43a3-b3df-172b8d09e7ba%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .
> > 
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/e7c82301-e7b7-4ea9-91e9-cbea714f1712%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e7c82301-e7b7-4ea9-91e9-cbea714f1712%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![vineeth\_mohan\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vineeth_mohan_2/32/747_2.png) [@vineeth\_mohan\_2](https://discuss.elastic.co/u/vineeth_mohan_2)\
**Post date:** [September 1, 2014, 3:13pm UTC](https://discuss.elastic.co/t/can-i-find-a-list-of-indices-containing-documents-which-contain-a-specified-term/19547/6 "2014-09-01T15:13:20Z")

</div>

Hello Chris ,

I am using ES 1.3.1  
Can you give it a try on that version.

Thanks  
Vineeth

On Mon, Sep 1, 2014 at 6:59 PM, Chris Lees [chris@fixspec.com](mailto:chris@fixspec.com) wrote:

> Same result I'm afraid...
> 
> {  
> "took": 62,  
> "timed\_out": false,  
> "\_shards": {  
> "total": 147,  
> "successful": 144,  
> "failed": 0  
> },  
> "hits": {  
> "total": 9975671,  
> "max\_score": 1.0,  
> "hits": [  
> ... results removed as data is sensitive, but I see correct  
> documents returned in here ...  
> ]  
> },  
> "aggregations": {  
> "aggs": {  
> "buckets":   
> }  
> }  
> }
> 
> I'm still running Elasticsearch 1.1.1 -- is this something that changed  
> after that perhaps?
> 
> Thanks for your help.
> 
> On Monday, September 1, 2014 2:23:17 PM UTC+1, vineeth mohan wrote:
> 
> > Hello Chris ,
> > 
> > That is strange , its working fine on my side.
> > 
> > Can you run the below and paste the result -
> > 
> > curl -XPOST '[http://localhost:9200/\_search](http://localhost:9200/_search)' -d '{  
> > "aggregations": {  
> > "aggs": {  
> > "terms": {  
> > "field": "\_index"  
> > }  
> > }  
> > }  
> > }'  
> > Thanks  
> > Vineeth
> > 
> > On Mon, Sep 1, 2014 at 6:17 PM, Chris Lees [ch...@fixspec.com](mailto:ch...@fixspec.com) wrote:
> > 
> > > Thanks Vineeth.
> > > 
> > > Unfortunately it doesn't return any results in the aggregations result.
> > > 
> > > Input query:  
> > > GET \_search
> > > 
> > > {  
> > > "aggregations": {  
> > > "aggs": {  
> > > "terms": {  
> > > "field": "\_index"  
> > > }  
> > > }  
> > > }  
> > > }
> > > 
> > > Result JSON showing 26K hits (correct), but no index aggregations:  
> > > {  
> > > "took": 4,  
> > > "timed\_out": false,  
> > > "\_shards": {  
> > > "total": 57,  
> > > "successful": 57,  
> > > "failed": 0  
> > > },  
> > > "hits": {  
> > > "total": 26622,  
> > > "max\_score": 1,  
> > > "hits": [...]  
> > > },  
> > > "aggregations": {  
> > > "aggs": {  
> > > "buckets":
> > > 
> > > ```
> > > }
> > > 
> > > ```
> > > 
> > > }  
> > > }
> > > 
> > > On Monday, September 1, 2014 1:40:00 PM UTC+1, vineeth mohan wrote:
> > > 
> > > > Hello Chris ,
> > > > 
> > > > This should work -
> > > > 
> > > > {  
> > > > "query" : {  
> > > > // GIVE QUERY HERE  
> > > > },  
> > > > "aggregations": {  
> > > > "aggs": {  
> > > > "terms": {  
> > > > "field": "\_index"  
> > > > }  
> > > > }  
> > > > }  
> > > > }
> > > > 
> > > > Thanks  
> > > > Vineeth
> > > > 
> > > > On Mon, Sep 1, 2014 at 3:10 PM, Chris Lees [ch...@fixspec.com](mailto:ch...@fixspec.com) wrote:
> > > > 
> > > > > I'm building a simple app which presents the user with two drop-downs  
> > > > > to easily filter data: one for day (mapping to my daily indices), and one  
> > > > > for client (a term within documents).
> > > > > 
> > > > > I'm currently finding indices using curl -XGET  
> > > > > localhost:9200/\_aliases, and a simple aggregation query to get a list of  
> > > > > known clients over all indices. It works, but since not every client is  
> > > > > present on every date it feels clunky when the client is known but the list  
> > > > > of dates still contains all indices, many of which are irrelevant for the  
> > > > > selected client.
> > > > > 
> > > > > Can anyone recommend a good way of finding a list of indices in which  
> > > > > there is at least one document containing a specified term please? Thank  
> > > > > you very much.
> > > > > 
> > > > > --  
> > > > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).
> > > > > 
> > > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > msgid/elasticsearch/3dcf46da-3eeb-4503-a348-365e3f0fd7a0%40goo  
> > > > > [glegroups.com](http://glegroups.com)  
> > > > > [https://groups.google.com/d/msgid/elasticsearch/3dcf46da-3eeb-4503-a348-365e3f0fd7a0%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/3dcf46da-3eeb-4503-a348-365e3f0fd7a0%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > > .  
> > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > 
> > > > --  
> > > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > msgid/elasticsearch/a485bf59-4ab6-43a3-b3df-172b8d09e7ba%  
> > > > [40googlegroups.com](http://40googlegroups.com)  
> > > > [https://groups.google.com/d/msgid/elasticsearch/a485bf59-4ab6-43a3-b3df-172b8d09e7ba%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/a485bf59-4ab6-43a3-b3df-172b8d09e7ba%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > .
> > > 
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > 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/e7c82301-e7b7-4ea9-91e9-cbea714f1712%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e7c82301-e7b7-4ea9-91e9-cbea714f1712%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/e7c82301-e7b7-4ea9-91e9-cbea714f1712%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/e7c82301-e7b7-4ea9-91e9-cbea714f1712%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/CAGdPd5kjcXygmKA77tuheiWJvWpGVvDTJ18a9\_42QVY7Eff41w%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGdPd5kjcXygmKA77tuheiWJvWpGVvDTJ18a9_42QVY7Eff41w%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Chris\_Lees](https://avatars.discourse-cdn.com/v4/letter/c/278dde/32.png) [@Chris\_Lees](https://discuss.elastic.co/u/Chris_Lees)\
**Post date:** [September 10, 2014, 9:18am UTC](https://discuss.elastic.co/t/can-i-find-a-list-of-indices-containing-documents-which-contain-a-specified-term/19547/7 "2014-09-10T09:18:31Z")

</div>

Apologies for delay -- upgrading took a while to get through./

You are right -- 1.3.2 resolved this issue and I'm now able to run  
aggregations on \_index.

Thanks for your help.

On Monday, September 1, 2014 4:13:31 PM UTC+1, vineeth mohan wrote:

> Hello Chris ,
> 
> I am using ES 1.3.1  
> Can you give it a try on that version.
> 
> Thanks  
> Vineeth
> 
> On Mon, Sep 1, 2014 at 6:59 PM, Chris Lees \<[ch...@fixspec.com](mailto:ch...@fixspec.com)  
> \<javascript:\>\> wrote:
> 
> > Same result I'm afraid...
> > 
> > {  
> > "took": 62,  
> > "timed\_out": false,  
> > "\_shards": {  
> > "total": 147,  
> > "successful": 144,  
> > "failed": 0  
> > },  
> > "hits": {  
> > "total": 9975671,  
> > "max\_score": 1.0,  
> > "hits": [  
> > ... results removed as data is sensitive, but I see correct  
> > documents returned in here ...  
> > ]  
> > },  
> > "aggregations": {  
> > "aggs": {  
> > "buckets":   
> > }  
> > }  
> > }
> > 
> > I'm still running Elasticsearch 1.1.1 -- is this something that changed  
> > after that perhaps?
> > 
> > Thanks for your help.
> > 
> > On Monday, September 1, 2014 2:23:17 PM UTC+1, vineeth mohan wrote:
> > 
> > > Hello Chris ,
> > > 
> > > That is strange , its working fine on my side.
> > > 
> > > Can you run the below and paste the result -
> > > 
> > > curl -XPOST '[http://localhost:9200/\_search](http://localhost:9200/_search)' -d '{  
> > > "aggregations": {  
> > > "aggs": {  
> > > "terms": {  
> > > "field": "\_index"  
> > > }  
> > > }  
> > > }  
> > > }'  
> > > Thanks  
> > > Vineeth
> > > 
> > > On Mon, Sep 1, 2014 at 6:17 PM, Chris Lees [ch...@fixspec.com](mailto:ch...@fixspec.com) wrote:
> > > 
> > > > Thanks Vineeth.
> > > > 
> > > > Unfortunately it doesn't return any results in the aggregations result.
> > > > 
> > > > Input query:  
> > > > GET \_search
> > > > 
> > > > {  
> > > > "aggregations": {  
> > > > "aggs": {  
> > > > "terms": {  
> > > > "field": "\_index"  
> > > > }  
> > > > }  
> > > > }  
> > > > }
> > > > 
> > > > Result JSON showing 26K hits (correct), but no index aggregations:  
> > > > {  
> > > > "took": 4,  
> > > > "timed\_out": false,  
> > > > "\_shards": {  
> > > > "total": 57,  
> > > > "successful": 57,  
> > > > "failed": 0  
> > > > },  
> > > > "hits": {  
> > > > "total": 26622,  
> > > > "max\_score": 1,  
> > > > "hits": [...]  
> > > > },  
> > > > "aggregations": {  
> > > > "aggs": {  
> > > > "buckets":
> > > > 
> > > > ```
> > > > }
> > > > 
> > > > ```
> > > > 
> > > > }  
> > > > }
> > > > 
> > > > On Monday, September 1, 2014 1:40:00 PM UTC+1, vineeth mohan wrote:
> > > > 
> > > > > Hello Chris ,
> > > > > 
> > > > > This should work -
> > > > > 
> > > > > {  
> > > > > "query" : {  
> > > > > // GIVE QUERY HERE  
> > > > > },  
> > > > > "aggregations": {  
> > > > > "aggs": {  
> > > > > "terms": {  
> > > > > "field": "\_index"  
> > > > > }  
> > > > > }  
> > > > > }  
> > > > > }
> > > > > 
> > > > > Thanks  
> > > > > Vineeth
> > > > > 
> > > > > On Mon, Sep 1, 2014 at 3:10 PM, Chris Lees [ch...@fixspec.com](mailto:ch...@fixspec.com) wrote:
> > > > > 
> > > > > > I'm building a simple app which presents the user with two drop-downs  
> > > > > > to easily filter data: one for day (mapping to my daily indices), and one  
> > > > > > for client (a term within documents).
> > > > > > 
> > > > > > I'm currently finding indices using curl -XGET  
> > > > > > localhost:9200/\_aliases, and a simple aggregation query to get a list of  
> > > > > > known clients over all indices. It works, but since not every client is  
> > > > > > present on every date it feels clunky when the client is known but the list  
> > > > > > of dates still contains all indices, many of which are irrelevant for the  
> > > > > > selected client.
> > > > > > 
> > > > > > Can anyone recommend a good way of finding a list of indices in which  
> > > > > > there is at least one document containing a specified term please? Thank  
> > > > > > you very much.
> > > > > > 
> > > > > > --  
> > > > > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).
> > > > > > 
> > > > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > > msgid/elasticsearch/3dcf46da-3eeb-4503-a348-365e3f0fd7a0%40goo  
> > > > > > [glegroups.com](http://glegroups.com)  
> > > > > > [https://groups.google.com/d/msgid/elasticsearch/3dcf46da-3eeb-4503-a348-365e3f0fd7a0%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/3dcf46da-3eeb-4503-a348-365e3f0fd7a0%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > > > .  
> > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > > 
> > > > > --  
> > > > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > msgid/elasticsearch/a485bf59-4ab6-43a3-b3df-172b8d09e7ba%  
> > > > > [40googlegroups.com](http://40googlegroups.com)  
> > > > > [https://groups.google.com/d/msgid/elasticsearch/a485bf59-4ab6-43a3-b3df-172b8d09e7ba%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/a485bf59-4ab6-43a3-b3df-172b8d09e7ba%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > > .
> > > > 
> > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > 
> > > --  
> > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/e7c82301-e7b7-4ea9-91e9-cbea714f1712%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e7c82301-e7b7-4ea9-91e9-cbea714f1712%40googlegroups.com)  
> > > [https://groups.google.com/d/msgid/elasticsearch/e7c82301-e7b7-4ea9-91e9-cbea714f1712%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/e7c82301-e7b7-4ea9-91e9-cbea714f1712%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .
> > 
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/25a714bc-6d73-480b-861c-f59c7ae7879b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/25a714bc-6d73-480b-861c-f59c7ae7879b%40googlegroups.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, 1:03am UTC](https://discuss.elastic.co/t/can-i-find-a-list-of-indices-containing-documents-which-contain-a-specified-term/19547/8 "2017-07-06T01:03:27Z")

</div>


