I have the following document stored in elastic search
{"Book_Id" : "102" ,"Book_Name" : "Alice in wonderLand", "Review_Text" :"DescentRead","Rating_Percentage" :"100" }'
{"Book_Id" : "102" ,"Book_Name" : "Alice in wonderLand", "Review_Text" :"For Kids","Rating_Percentage" :"50" }'
{"Book_Id" : "103" ,"Book_Name" : "Blah Blah", "Review_Text" :"Great","Rating_Percentage" :"100" }'
I want to do a search and retrieve only one field(Review Text in this example) as an out put.I am using the following code
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.query(QueryBuilders.matchQuery("Book_Id", "102"))
.fields("_source.Review_Text");
Search search = new Search.Builder(searchSourceBuilder.toString())
.addIndex("reviews")
.addType("bookreview")
.build();
SearchResult result = client.execute(search);
But I keep getting the error -
{"error":{"root_cause":[{"type":"parsing_exception","reason":"Deprecated field [fields] used, expected [stored_fields] instead","line":10,"col":14}],
what is missing here ? How else do we retrieve only specific fileds instead of all the fields as Json
Thanks Shabna