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

Add multi percolate api #3488

Closed
martijnvg opened this Issue Aug 12, 2013 · 0 comments

Comments

Projects
None yet
1 participant
@martijnvg
Copy link
Member

commented Aug 12, 2013

The multi percolate allows the bundle multiple percolate requests into one request. This api works similar to the multi search api.

The request body format is line based. Each percolate request item takes two lines, the first line is the header and the second line is the body.

The header can contain any parameter that normally would be set via the request path or query string parameters. There are several percolate actions, because there are multiple types of percolate requests:

  • percolate - Action for defining a regular percolate request.
  • count - Action for defining a count percolate request.

Each action has its own set of parameters that need to be specified in the percolate action.
Format:

{"[header_type]" : {[options...]}
{[body]}

Depending on the percolate action different parameters can be specified. For example the percolate and percolate existing document actions support different parameters.

The following endpoints are supported:

POST localhost:9200/[index]/[type]/_mpercolate
POST localhost:9200/[index]/_mpercolate
POST localhost:9200/_mpercolate

The index and type defined in the url path are the default index and type.

Example

Request:

curl -XGET 'localhost:9200/twitter/tweet/_mpercolate' --data-binary @requests.txt; echo

The index twitter is the default index and the type tweet is the default type and will be used in the case a header doesn't specify an index or type.

requests.txt:
{"percolate" : {"index" : twitter", "type" : "tweet"}}
{"doc" : {"message" : "some text"}}
{"percolate" : "index" : twitter", "type" : "tweet", "id" : "1"}
{}
{"percolate" : "index" : users", "type" : "user", "id" : "3", "percolate_index" : "users_2012" }
{"size" : 10}
{"count" : {"index" : twitter", "type" : "tweet"}}
{"doc" : {"message" : "some other text"}}
{"count" : "index" : twitter", "type" : "tweet", "id" : "1"}
{}

For a percolate existing document item (headers with the id field), the response can be an empty json object. All the required options are set in the header.

Response:

{
    "items" : [
        {
            "took" : 24,
            "_shards" : {
                "total" : 5,
                "successful" : 5,
                "failed" : 0,
            },
            "total" : 3,
            "matches" : ["1", "2", "3"]
        },
        {
            "took" : 12,
            "_shards" : {
                "total" : 5,
                "successful" : 5,
                "failed" : 0,
            },
            "total" : 3,
            "matches" : ["4", "5", "6"]
        },
        {
            "error" : "[user][3]document missing"
        },
        {
            "took" : 12,
            "_shards" : {
                "total" : 5,
                "successful" : 5,
                "failed" : 0,
            },
            "total" : 3
        },
        {
            "took" : 14,
            "_shards" : {
                "total" : 5,
                "successful" : 5,
                "failed" : 0,
            },
            "total" : 3
        }
    ]
}

Each item represents a percolate response, the order of the items maps to the order in where the percolate requests were specified. In case a percolate request failed, the item response is substituted with an error message.

@ghost ghost assigned martijnvg Aug 12, 2013

@martijnvg martijnvg closed this in bc0abd8 Aug 12, 2013

This was referenced Aug 12, 2013

karmi added a commit to elastic/elasticsearch-ruby that referenced this issue Jan 23, 2014

karmi added a commit to elastic/elasticsearch-ruby that referenced this issue Jan 24, 2014

karmi added a commit to elastic/elasticsearch-ruby that referenced this issue Jan 24, 2014

karmi added a commit to elastic/elasticsearch-ruby that referenced this issue Jan 28, 2014

karmi added a commit to elastic/elasticsearch-ruby that referenced this issue Jan 29, 2014

karmi added a commit to elastic/elasticsearch-ruby that referenced this issue Jan 29, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.