noop由于不滿足條件,我的腳本更新會產生以下回應:
/my_idx/_update/my_doc_id
{
"_index": "my_idx",
"_type": "_doc",
"_id": "my_doc_id",
"_version": 4,
"result": "noop",
"_shards": {
"total": 0,
"successful": 0,
"failed": 0
}
}
但是,由于其超級建構式在 中施加的約束,特別是在 和 周圍,客戶端無法反序列化此回應UpdateResponse<TDocument>,更新回應中顯然缺少這些約束:elasticsearch-javaWriteResponseBaseprimaryTermseqNonoop
protected WriteResponseBase(AbstractBuilder<?> builder) {
this.id = ApiTypeHelper.requireNonNull(builder.id, this, "id");
this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index");
this.primaryTerm = ApiTypeHelper.requireNonNull(builder.primaryTerm, this, "primaryTerm");
this.result = ApiTypeHelper.requireNonNull(builder.result, this, "result");
this.seqNo = ApiTypeHelper.requireNonNull(builder.seqNo, this, "seqNo");
this.shards = ApiTypeHelper.requireNonNull(builder.shards, this, "shards");
this.type = builder.type;
this.version = ApiTypeHelper.requireNonNull(builder.version, this, "version");
this.forcedRefresh = builder.forcedRefresh;
}
我的 Java 客戶端版本是8.4.2,而服務器實體版本是7.2.0. 我已經不得不做一些hack來讓這兩個版本一起作業。我想知道這些缺失的欄位在7.2.0. 不幸的是,我無法檢查,因為它們只有Github7.15.0中的標簽。
是否有任何變通方法,或者捕獲生成的例外并處理它(希望是因為noop)是讓它作業的唯一方法?
uj5u.com熱心網友回復:
這個 github 問題中報告了 Noop 的更新回應與真正更新的檔案之間的不一致。這個PR已在 Elasticsearch 7.4.0 版中發布,已在該版本的發行說明中確認。
話雖如此,我認為最干凈的解決方案是將 Elasticsearch(考慮到 v.7.2.0 已經超過 2 年)更新到 >=7.4.0 的版本,或者將detect_noop標志添加到您的請求中。請記住,即使檔案本身實際上沒有更新,這也會強制檔案的版本號始終更新。
此外,我認為不能保證版本 8 中的 REST 客戶端可以與 Elasticsearch 7.x 一起使用,更不用說版本 7.2 了。Elasticsearch 服務器兼容性策略明確指出客戶端是向前兼容的。但是您正在嘗試以向后兼容的方式使用它。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/533376.html
標籤:弹性搜索elasticsearch-java-apielasticsearch-java-api-客户端
