-
Notifications
You must be signed in to change notification settings - Fork 25k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scripting: ctx[_version] in update by query returns -1 since 6.7 #55745
Comments
Pinging @elastic/es-core-infra (:Core/Infra/Scripting) |
TODO: test passing |
After checking fetch version, let's ask the distrib folks. |
Any update on this? Issue still exists in 7.16.2. Additionally, a similar problem can be observed when trying to set _version from an ingest pipeline:
Resulting field has -3 for all documents, regardless of the actual _version. |
To get the version as part of the document you need to pass in |
diff --git a/modules/reindex/src/main/java/org/elasticsearch/reindex/TransportUpdateByQueryAction.java b/modules/reindex/src/main/java/org/elasticsearch/reindex/TransportUpdateByQueryAction.java
index 0f1a98ac085..6674a187cdd 100644
--- a/modules/reindex/src/main/java/org/elasticsearch/reindex/TransportUpdateByQueryAction.java
+++ b/modules/reindex/src/main/java/org/elasticsearch/reindex/TransportUpdateByQueryAction.java
@@ -18,6 +18,7 @@ import org.elasticsearch.client.internal.ParentTaskAssigningClient;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.inject.Inject;
+import org.elasticsearch.core.Booleans;
import org.elasticsearch.index.reindex.BulkByScrollResponse;
import org.elasticsearch.index.reindex.BulkByScrollTask;
import org.elasticsearch.index.reindex.ScrollableHitSource;
@@ -101,7 +102,7 @@ public class TransportUpdateByQueryAction extends HandledTransportAction<UpdateB
super(
task,
// use sequence number powered optimistic concurrency control
- false,
+ Boolean.TRUE.equals(request.getSearchRequest().source().version()),
true,
logger,
client, |
Allow UpdateByQuery to read the doc version if set in the request via `version=true`. If `version=true` is unset or false, the `ctx._version` is `-1` indicating internal versioning via seq. Fixes: elastic#55745
Allow UpdateByQuery to read the doc version if set in the request via `version=true`. If `version=true` is unset or false, the `ctx._version` is `-1` indicating internal versioning via seq. Fixes: #55745
In
TransportUpdateByQueryAction
we always createAsyncIndexBySearchAction
withneedsSourceDocumentVersions=false
, so the versions are never fetched. This was on the switch to sequence numbers: #37857.The documentation still refers to
ctx['_version']
and we still populate that key in the context.The text was updated successfully, but these errors were encountered: