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"))
.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

Post Your Public Answer

Your name (required)
Your email address (required)
Answer (required)
support@searchly.com
http://assets1.desk.com/
false
searchboxio
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/en/portal/articles/autocomplete