ElasticSearch Count API


(Virgile Devaux-2) #1

in http://www.elasticsearch.org/guide/reference/api/count.html it's
said that:
"The query is optional, and when not provided, it will use
match_all to count all the docs."
But if I don't set a query parameter, I get the following error:
{"error":"No query to execute, not in body, and not bounded to 'q'
parameter"}%

The gist: https://gist.github.com/1510709 illustrates this point.

Is this something that will change soon? If not, what is the best
(performance) way of requesting a count for all the document in the
indices/types?


(Clinton Gormley) #2

On Thu, 2011-12-22 at 07:41 -0800, Virgile Devaux wrote:

in http://www.elasticsearch.org/guide/reference/api/count.html it's
said that:
"The query is optional, and when not provided, it will use
match_all to count all the docs."
But if I don't set a query parameter, I get the following error:
{"error":"No query to execute, not in body, and not bounded to 'q'
parameter"}%

What version of ES are you using? Up until recently, ES did require a
query. If you've got an older version, then you can do this:

curl -XGET http://localhost:9200/_count -d '{ match_all: {}}'

clint


(system) #3