Support Center

Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Issues with jest Client

Shabna Aug 09, 2017 09:18PM +03

I have the following document stored in elastic search and using Jest client to retrieve the data

{"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"))
Search search = new Search.Builder(searchSourceBuilder.toString())

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

Post Your Public Answer

Your name (required)
Your email address (required)
Answer (required)
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
Invalid characters found