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

Commits on Mar 24, 2014

  1. Added update by query 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.
    martijnvg committed Mar 24, 2014
    Copy the full SHA
    9cd32e1 View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    0b3d129 View commit details
    Browse the repository at this point in the history
  3. Updated to master 2.

    Ported the tests to ElasticSearchIntegrationTests
    Removed duplicate update code, with UpdateHelper (which get used via bulk api logic)
    martijnvg committed Mar 24, 2014
    Copy the full SHA
    abbba87 View commit details
    Browse the repository at this point in the history

Commits on Mar 25, 2014

  1. Updated license headers.

    Removed usage of forbidden apis.
    martijnvg committed Mar 25, 2014
    Copy the full SHA
    9cd7c0f View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    503d16d View commit details
    Browse the repository at this point in the history