專案中使用了客戶端RestHighLevelClient7,配置雙資料源 分別操作elasticsearch5、elasticsearch7,兩個版本的最大區別就是type引數;
elasticsearch5一個index下可以有多個type,而elasticsearch7下不能設定type,默認_doc;
在使用GetRequest rquest=new GetRequest(index,type,id)查詢單個檔案時沒有問題
GetResponse response=rhlc.get(rquest, RequestOptions.DEFAULT)
回傳正確結果
在使用查詢SearchReques時設定type會有問題
SearchRequest searchRequest = new SearchRequest();
searchRequest.indices("index");
searchRequest.types("type"); //該方法已過時,但是不知道如何設定type
searchRequest.source(sourceBuilder);
SearchResponse response = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
拋出的例外
{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"request [/index/type/_search] contains unrecognized parameters: [ccs_minimize_roundtrips], [ignore_throttled]"}],"type":"illegal_argument_exception","reason":"request [/index/type/_search] contains unrecognized parameters: [ccs_minimize_roundtrips], [ignore_throttled]"},"status":400}
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/251865.html
標籤:其他數據庫
上一篇:pb解密演算法實作
