Best practice for TDocument class reference to pass to Java's ElasticsearchClient methods?

I am using the latest Java REST API client and wondering what Class<TDocument> reference I should be passing to the search() method in case of no object domain model is being used.

At present I am using a bare Map.class and things are working as expected, though @SuppressWarnings("rawtypes") is needed: see for example

Is such approach correct? TIA

If you don't need to get the documents, you can pass Void.

Otherwise ObjectNode. See Reading documents by id | Elasticsearch Java API Client [8.10] | Elastic

Thank you very much @dadoonet it seems I did miss the part about ObjectNode from the docs.
The Void option is indeed very interesting, I'd suggest to include it in the docs as well.


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