diff --git a/USER_GUIDE.md b/USER_GUIDE.md index 4ab999df6d..58151f805a 100644 --- a/USER_GUIDE.md +++ b/USER_GUIDE.md @@ -9,6 +9,7 @@ - [Create an index](#create-an-index) - [Index data](#index-data) - [Search for the documents](#search-for-the-documents) + - [Get raw JSON results](#get-raw-json-results) - [Search documents using a match query](#search-documents-using-a-match-query) - [Bulk requests](#bulk-requests) - [Aggregations](#aggregations) @@ -130,6 +131,17 @@ for (int i = 0; i < searchResponse.hits().hits().size(); i++) { } ``` +### Get raw JSON results + +When the target class is not defined or if the response result is a semi-structured data not tied to an object definition, use a raw JSON data representation as the target class. For example, the below snippet uses `ObjectNode` from jackson. + +```java +SearchResponse searchResponse = client.search(b -> b.index(index), ObjectNode.class); +for (int i = 0; i < searchResponse.hits().hits().size(); i++) { + System.out.println(searchResponse.hits().hits().get(i).source()); +} +``` + ## Search documents using a match query ```java