I have a Python script that runs many ElasticSearch aggregates, for example:
client = Elasticsearch(...)
q = {"aggs": {"my_name":{"terms": "field", "fieldname"}}}
res = client.search(index = "indexname*", doc_type = "doc_type", body = q)
But this returns a search query (match everything I think) res["hits"]and aggregation results res["aggregations"].
What I want to run is the Python equivalent of the following
GET /index*/doc_type/_search?search_type=count
{"aggs": {"my_name":{"terms": "field", "fieldname"}}}
How can I enable ?search_type=countwhen using Python Elasticsearch?
I would like to know this in general, but the current reason I look at it, I sometimes get errors caused by timeouts or data size when starting queries. My suspicion is that if I can only ask for a count, then I will avoid them.
source
share