Skip to content
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

Added update by query api. #2230 #2231

Closed
wants to merge 5 commits into from

Conversation

martijnvg
Copy link
Member

No description provided.

@Paikan
Copy link
Contributor

Paikan commented Oct 22, 2012

Is it planned to push this one soon?

@devilankur18
Copy link

Please release this one. This is in big demand

#1607

ofavre pushed a commit to yakaz/elasticsearch-action-updatebyquery that referenced this pull request Feb 13, 2013
@ofavre ofavre mentioned this pull request Feb 13, 2013
@ofavre
Copy link
Contributor

ofavre commented Feb 13, 2013

I've packaged it as a plugin: yakaz/elasticsearch-action-updatebyquery.
Have fun.

@ofavre
Copy link
Contributor

ofavre commented Mar 1, 2013

The plugin is now ported to ElasticSearch 0.90.0.Beta1!

@ofavre
Copy link
Contributor

ofavre commented Mar 6, 2013

I've added some more fields in the context.
See the corresponding README section and the commit.

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.
@clintongormley
Copy link

Blocked by #6914

@tobigue
Copy link
Contributor

tobigue commented Aug 13, 2014

+1 for an update by query possibility

@clintongormley clintongormley added the :Distributed/CRUD A catch all label for issues around indexing, updating and getting a doc by id. Not search. label Nov 11, 2014
ofavre pushed a commit to yakaz/elasticsearch that referenced this pull request Nov 13, 2014
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.
dakrone pushed a commit that referenced this pull request Nov 14, 2014
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 #1607, #2230, #2231.
dakrone pushed a commit that referenced this pull request Nov 14, 2014
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 #1607, #2230, #2231.
@jpountz
Copy link
Contributor

jpountz commented Nov 21, 2014

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.

@jpountz jpountz closed this Nov 21, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed/CRUD A catch all label for issues around indexing, updating and getting a doc by id. Not search. stalled
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants