Using SearchType "count" alternatives

I have a use case where I need to use the "size" parameter in my query. I have seen the recommendation to perform two queries-- one to retrieve the count, and a second query using that count as the "size" parameter, to ensure I'm getting all my results without having to set "size" to MAX_INTEGER.

I am using JestClient to execute my query-- when I try the following search, I get the error below:

        final Search countSearch = new Search.Builder(searchSourceBuilder.toString())
"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"No search type for [count]"

Online I am seeing that the count search type is deprecated, and that we should use "size = 0" for this purpose. However using "size = 0" just returns 0 results for me.

Using Scroll doesn't work for my use case, because on the client side these data are going to be downloaded into a csv file, not displayed in a UI.

What are my options for this? Thanks!

Any advice on this one? Thanks!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.