Skip to content

Improved percolation api #4317

@felipellrocha

Description

@felipellrocha

Hey guys,

I was working with the percolator earlier today, and I thought of a nice way to improve its api. So, right now, if I register a query using the percolator:

curl -XPUT localhost:9200/_percolator/test/kuku -d '{
    "query" : {
        "term" : {
            "field1" : "value1"
        }
    }
}'

and I percolate a matching document

curl -XGET localhost:9200/test/type1/_percolate -d '{
    "doc" : {
        "field1" : "value1"
    }
}'

I get something of the effect back:

{"ok":true, "matches":["kuku"]}

Which a fine way of doing things, but I think it'd be nicer to be able to register metadata along with the query. So, something of the effect:

curl -XPUT localhost:9200/_percolator/test/ -d '{
    "query" : {
        "term" : {
            "field1" : "value1"
        }
    },
    "meta": {
        "campaign": 1,
        "user_id": 1,
        "user_name": kuku
    }
}'

If a document matched, I'd get something like this back:

{"ok":true, "matches":[{"_id": "BzA9dR7OSqGylX-0y80IJA", "campaign": 1, "user_id": 1, "user_name": kuku}]}

Currently, if I need to store more information about a query, I need to do hacks, such as concatenating strings with all the information I want to get back from that match (example: "campaign:1-id:1-name:kuku") to use as the id of that document, but that has drawbacks.

What do you guys think?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions