Make Elasticsearch return the number of all documents on query -
when query elasticsearch returns how many hits get. can reply how many documents has in total? here i've added imaginary field sum_documents result. such thing exist, or have make query fetch sum?
{ "took" : 1, "timed_out" : false, "_shards" : { "total" : 5, "successful" : 5, "failed" : 0 }, "hits" : { "total" : 0, "sum_documents": 500, "max_score" : null, "hits" : [ ] } }
you can add global
aggregation in query, , return total document count in search context (index/alias + type(s))
{ "query": { "query_string": { "query": "viking", "default_operator": "and" } }, "aggs": { "harvester-test": { "global": {} } } }
Comments
Post a Comment