Hi Curt,
You need to add "size" : 0.
For example, this should work:
$ curl -XPOST localhost:9200/_search?pretty=true -d '{"query" : {
"match_all" : {}}, "size" : 0}'
On Wednesday, July 4, 2012 9:21:59 AM UTC+3, Curt wrote:
Hi, Thanks for reply. How about using REST API?
On Wednesday, July 4, 2012 1:35:28 PM UTC+8, Zhibin wrote:
Are you querying through REST API or JAVA API?
If using Java, On the SearchRequestBuilder
-setSize(0)
-setSearchType(SearchType.COUNT)To get the number of hits, use response.hits().getTotalHits(), assuming
response is your SearchResponseRegards,
ZhibinOn Wednesday, 4 July 2012 13:08:23 UTC+8, Curt wrote:
I want to write a query to return only number of hits for a specific
query, seemed that _count API doesn't work. is there any solution for this?