I have multiple Elasticsearch 1.3.2 indices, and I'm using custom
document IDs. I want to find the number of distinct IDs across my
indices. Some documents have the same ID but are in different indices,
so this is different from just counting documents. So I wanted to do a
cardinality aggregation on the _id field. So I posted this to http://localhost:9200/my_indices/_search:
{ "from": 0, "size": 0, "aggregations": { "_count": { "cardinality": { "script": "doc['_id'].value", "lang": "groovy" } } } }
But Elasticsearch just sent back this:
{ "took": 60, "timed_out": false, "_shards": { "total": 175, "successful": 175, "failed": 0 }, "hits": { "total": 310714, "max_score": 0, "hits": [] }, "aggregations": { "_count": { "value": 0 } }
I'm pretty sure there's more than 0 IDs in there! What happened, and is it possible to get what I want?