Empty search response intermittently for same query


I’m using Opensearch v1.2 with java-high-level-rest-client in a spring-boot application. And facing an issue intermittently.

So, for the same query sometimes I’m getting an empty response/hits. Whereas when I run the query again it returns the correct documents.

I’m not sure if this is something related to opensearch index settings (using default one) or with java threads. My initial guess was that this might be cause of refreshInterval, but the documents are static and it’s a local instance of opensearch so no modifications to documents are happening.

Here’s the code that executes search, using sync search:

final SearchRequest searchRequest = new SearchRequest(indices)
                .source(queryBuilderToSearchSourceBuilder(builder, from, size))
            log.info("searching {} with {}", Arrays.asList(indices), searchRequest);
            return client.search(searchRequest, RequestOptions.DEFAULT);

And buildIndicesOptions function looks like this:

IndicesOptions buildIndicesOptions() {
        return IndicesOptions.fromOptions(true, false, true, false);

Thanks for any help :slight_smile: