From 0da2119c4c469fd8adbd1597fbf3bcdc460bdfc9 Mon Sep 17 00:00:00 2001 From: Vacha Shah Date: Fri, 3 Mar 2023 00:22:25 +0000 Subject: [PATCH] Addressing comments Signed-off-by: Vacha Shah --- USER_GUIDE.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/USER_GUIDE.md b/USER_GUIDE.md index fef0f4205e..58151f805a 100644 --- a/USER_GUIDE.md +++ b/USER_GUIDE.md @@ -9,7 +9,7 @@ - [Create an index](#create-an-index) - [Index data](#index-data) - [Search for the documents](#search-for-the-documents) - - [Get results in terms of raw JSON](#get-results-in-terms-of-raw-json) + - [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) @@ -131,12 +131,15 @@ for (int i = 0; i < searchResponse.hits().hits().size(); i++) { } ``` -### Get results in terms of raw JSON +### 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 search = client.search(b -> b.index(index), ObjectNode.class); +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