-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Added update by query api. #2230 #2231
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
Conversation
Is it planned to push this one soon? |
Please release this one. This is in big demand |
I've packaged it as a plugin: yakaz/elasticsearch-action-updatebyquery. |
The plugin is now ported to ElasticSearch 0.90.0.Beta1! |
I've added some more fields in the context. This feature would be nice as part of the Update API too, should I make a pull request, or are you planning on integrating Update By Query API and merging it a bit code-wise with the regular Update API? |
The update by query API allows all documents that with the query to be updated with a script. This feature is experimental. The update by query works a bit different than the delete by query. The update by query api translates the documents that match into bulk index / delete requests. After the bulk limit has been reached, the bulk requests created thus far will be executed. After the bulk requests have been executed the next batch of requests will be prepared and executed. This behavior continues until all documents that matched the query have been processed. The bulk size can be configured with the *action.updatebyquery.bulk_size* option in the elasticsearch configuration. For example: `action.updatebyquery.bulk_size=2500` The commit relates to issue elastic#2230 Example usage ================================================= Index an example document: curl -XPUT 'localhost:9200/twitter/tweet/1' -d ' ``` { "text" : { "message" : "you know for search" } } ``` Execute the following update by query command: curl -XPOST 'localhost:9200/twitter/_update_by_query' -d ' ``` { "query" : { "term" : { "message" : "you" } }, "script" : "ctx._source.field1 += 1" } ``` This will yield the following response: ``` { "ok" : true, "took" : 9, "total" : 1, "updated" : 1, "indices" : [ { "twitter" : { } } ] } ``` By default no bulk item responses are included in the response. If there are bulk item responses included in the response, the bulk response items are grouped by index and shard. This can be controlled by the `response` option. Options ===================================================== Additional general options in request body: * `lang`: The script language. * `params`: The script parameters. Query string options ----------------------------------------------------- * `replication`: The replication type for the delete/index operation (sync or async). * `consistency`: The write consistency of the index/delete operation. * `response`: What bulk response items to include into the update by query response. This can be set to the following: `none`, `failed` and `all`. Defaults to none. Warning: `all` can result in out of memory errors when the query results in many hits. * `routing` : Sets the routing that will be used to route the document to the relevant shard. * `timeout` : Timeout waiting for a shard to become available.
Ported the tests to ElasticSearchIntegrationTests Removed duplicate update code, with UpdateHelper (which get used via bulk api logic)
Removed usage of forbidden apis.
Blocked by #6914 |
+1 for an update by query possibility |
In addition to `_source`, the following variables are available through the `ctx` map: `_index`, `_type`, `_id`, `_version`, `_routing`, `_parent`, `_timestamp`, `_ttl`. Some of these fields are more useful still within the context of an Update By Query, see elastic#1607, elastic#2230, elastic#2231.
As we want to implement this feature by using a task management infrastructure, I am closing this pull request. Discussion can still continue on #2230. |
No description provided.