Search in elasticsearch 8


In v.7.X the search performed as follow:

searchResponse =, RequestOptions.DEFAULT);

How do I perform search in v.8 without defining the target class for the matching documents. (I want to keep it as json without searlization, without specifying Product class)

searchResponse =, Product.class);

I think you can use Void.class.
And do something like this to get the JSON Response:

I tried:

searchResponse =, Void.class);

Failed with:

The method search(SearchRequest, Class<TDocument>) in the type ElasticsearchClient is not applicable for the arguments (SearchRequest, Class<Void>)	

@swallez Do you know?

Can you help with it?

I'm not sure why Void.class does not work here, but for your purpose I would try to have the response read as raw json, using for instance ObjectNode.class as in

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