Restrict percolator call to a type

As explained in the dochttp://www.elasticsearch.org/guide/reference/api/percolate.html,
when I store a query with _percolator, eg:

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

This query will be run when I percolate a document on the 'test' index, but
if I want to restrict it to the type 'foo' of the 'test' index the only
solution is to add a type in the query :

curl -XPUT localhost:9200/_percolator/test/kuku -d '{
"type":"foo",
"color" : "blue",
"query" : {
"term" : {
" field1" : "value1"
}
}
}'

And when adding the document use

curl -XGET localhost:9200/test/type1/_percolate -d '{
"doc" : {
"field1" : "value1"
},
"query" : {
"term" : {
"type" : "foo"
}
}
}'

Is there another solution ?
I tried
curl -XPUT localhost:9200/_percolator/test/foo/kuku
but it does not work.

--

Hello Jecom,

If specify the type when you percolate a document, you shouldn't need
to specify it in the JSON data. So this should be enough:

curl -XGET localhost:9200/test/test_type/_percolate -d '{

"doc" : {
    "field1" : "value1 value2"
}

}'

However, when you add the percolator, you need to specify the type
within the query. For example:

curl -XPUT localhost:9200/_percolator/test/kuku2 -d '{
"query" : {
"bool": {
"must": [
{
"term" : {
"field1" : "value1"
}
},
{
"term": {
"_type": "test_type"
}
}
]
}
}
}'

Best regards,
Radu

http://sematext.com/ -- Elasticsearch -- Solr -- Lucene

On Wed, Oct 24, 2012 at 4:53 PM, Jecom jmaynier@eco2market.com wrote:

As explained in the doc, when I store a query with _percolator, eg:

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

This query will be run when I percolate a document on the 'test' index, but
if I want to restrict it to the type 'foo' of the 'test' index the only
solution is to add a type in the query :

curl -XPUT localhost:9200/_percolator/test/kuku -d '{
"type":"foo",
"color" : "blue",
"query" : {
"term" : {
" field1" : "value1"
}
}
}'

And when adding the document use

curl -XGET localhost:9200/test/type1/_percolate -d '{
"doc" : {
"field1" : "value1"
},
"query" : {
"term" : {
"type" : "foo"
}
}
}'

Is there another solution ?
I tried
curl -XPUT localhost:9200/_percolator/test/foo/kuku
but it does not work.

--

--