I would like to update a partial document by query using Elasticsearch 2.4.
I don't want to use the scripts tag because I don't want to enumerate all the fields, I would like to use a doc property like the simple update method. However it's not possible to write this part of the following code:
doc: MY_PARTIAL_DOC,
So the following code doesn't work:
client.updateByQuery(
{
index: MY_INDEX,
type: MY_TYPE,
body: {
query: { MY_QUERY
},
doc: MY_PARTIAL_DOC,
}
},
MY_CALLBACK
);
Is there a solution? I have a workaround at the moment but I would like to update my document by query using only one request. Thanks.
Instead of this script property I'd like to use a doc property, like the one for the update API because I want to update most of the properties of a document. But this property doesn't exist for the updateByQuery API.
I'm happy to use any other API. However, for the reindex API, the Elasticsearch documentation says "Just like _update_by_query, _reindex gets a snapshot of the source index but its target must be a different index so version conflicts are unlikely". So I don't think this API is suitable for my needs since I don't want to change the index. I would like to update the document as a partial one.
It's what I would have liked to avoid. Because I want to update only one document each time. For now I'm doing that, but I would have prefered to process only one update instead of a get and then an update. Even if I know an update is not only an update under the hood.
I'd like to use Elasticsearch as a datastore and not only as a search engine. I understand this kind of feature is not really necessary for a search engine. I don't have to do many updates, so getting the data before updating them is acceptable.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.