Search in elasticsearch 8

Hi,

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

searchResponse = client.search(searchRequest, 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 = client.search(searchRequest, Product.class);

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

I tried:

searchResponse = client.search(searchRequest, 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
https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/reading.html#_reading_raw_json

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