0
使用JestClient特定的Fileds我已經存儲在檢索彈性貨品搜尋
{"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" }'
我想做一個搜索和檢索只有一個字段(在本例中審查文本)作爲出把彈性搜索下列文件。我正在使用以下代碼
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);
但我不斷收到錯誤 -
{"error":{"root_cause":[{"type":"parsing_exception","reason":"Deprecated field [fields] used, expected [stored_fields] instead","line":10,"col":14}],
這到底是怎麼失蹤了?做怎麼回事,我們只檢索特定的Fileds,而不是所有的字段爲JSON
感謝 Shabna
fetchSource對於SearchSourceBuilder是未定義的。 – Sajna
您使用的是哪個版本的elasticsearch庫? – Val
得到它的工作!更改彈性serach版本後非常感謝 – Sajna