prepareCount API deprecated from 2.1. The alternate not working

(Trupti Mali) #1

PrepareCount API has been deprecated from 2.1 . I was trying the alternate way of using prepareSearch with setSize as zero. But that didnt seem to work. It basically returned me no values at all.

SearchRequestBuilder srBuilder = client.prepareSearch();
srBuilder.setQuery(queryBuilder); ///added a termQuery

Am I doing anything wrong here?

(David Pilato) #2

What do you mean by "no value"?

How does the response object look like?

(Luca Cavanna) #3

do you do srBuilder.get() somewhere to actually send the request and get back the response? This type of request provides no results but the total hits will contain the number of matching documents.

(Trupti Mali) #4

Ah Right !! I think you were right - I was looking into the array returned and not at total hits variable

Thanks Luca

(system) #5