prepareCount API deprecated from 2.1. The alternate not working

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?

What do you mean by "no value"?

How does the response object look like?

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.

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

Thanks Luca