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

Percolating existing document api #3380

Closed
martijnvg opened this issue Jul 24, 2013 · 4 comments
Closed

Percolating existing document api #3380

martijnvg opened this issue Jul 24, 2013 · 4 comments

Comments

@martijnvg
Copy link
Member

A common use case is to percolate a document that has just been indexed. A big advantage would be to just specify the index, type and id of a document (which is returned with each index response) that has just been indexed, internally a get request can then fetch the content of the recently indexed document and then the percolate api will execute on that.

Percolate an existing document with id 1 and type tweet from index twitter:

curl -XGET 'localhost:9200/twitter/tweet/1/_percolate'

Percolate an existing document with id 2 and type tweet from index twitter-2013: (percolating 2013 tweet against 2012 queries)

curl -XGET 'localhost:9200/twitter-2013/tweet/2/_percolate?percolate_index=twitter-2012'

Additional options for percolating an existing document on top of existing percolator options:

  • id - The id of the document to retrieve the source for.
  • percolate_index - The index containing the percolate queries. Defaults to the index defined in the url.
  • percolate_type - The percolate type (used for parsing the document). Default to type defined in the url.
  • routing - The routing value to use when retrieving the document to percolate.
  • preference - Which shard to prefer when retrieving the existing document.
  • percolate_routing - The routing value to use when percolating the existing document.
  • percolate_preference - Which shard to prefer when executing the percolate request.
  • version - Enables a version check. If the fetched document's version isn't equal to the specified version then the request fails with a version conflict and the percolation request is aborted.
  • version_type - Whether internal or external versioning is used. Defaults to internal versioning.

Internally the percolate api will issue a get request for fetching the_source of the document to percolate.
For this feature to work the _source for documents to be percolated need to be stored.

@ghost ghost assigned martijnvg Jul 24, 2013
martijnvg added a commit that referenced this issue Jul 29, 2013
The percolate existing doc feature now reuses the get request instead of having a separate request body.
Relates to #3380
@phrone
Copy link

phrone commented Dec 30, 2013

Hi! Great work, but would it be possible to use a specified document field instead of the _source?

@martijnvg
Copy link
Member Author

@phrone This is actually possible via get source filtering [1], but it just needs to be exposed to the percolate rest api.

1: http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/docs-get.html#get-source-filtering

@fransflippo
Copy link
Contributor

Just what I need! Is this included in the Java API yet?

@martijnvg
Copy link
Member Author

@fransflippo Yes, it is included in the Java api. There is a PercolateRequestBuilder#setGetRequest(GetRequest) method. The passed get request is internally used to fetch the document needed for percolating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants