0

As it can read from the oficial Java API documentation, We can set the "query_cache" param.

But, there is none method on CountRequestBuilder to set request params.

Which is the right way to set params in request from Java API?, specially for the exposed kind, the Count request.

3 Answers 3

1

Count api has been removed.

The deprecated count api has been removed from the Java api, use the search api instead and set size to 0.

The following call

client.prepareCount(indices).setQuery(query).get();

can be replaced with

client.prepareSearch(indices).setSource(new SearchSourceBuilder().size(0).query(query)).get();

Source

Sign up to request clarification or add additional context in comments.

Comments

0

Here is one example for running a count query with Java:

CountResponse response = client.prepareCount(INDEX)
        .setQuery(new TermQueryBuilder("_type", TYPE))
        .execute()
        .actionGet();

1 Comment

Thank you for for your support Jeff, but that is not the question, read it again please.
0

As me said in #1, CountRequestBuilder doesn't has any way to specify "query_cache" param, the only one way to achieve this approach is working with SearchRequestBuilder in this way.

this.transportClient.prepareSearch(...).setTypes(...)
                .setSearchType(SearchType.COUNT)
                .setQuery(...)
                .setQueryCache(true)
                .execute().actionGet();

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.