# Restrict percolator call to a type

**URL:** <https://discuss.elastic.co/t/restrict-percolator-call-to-a-type/9458>\
**Category:** Elasticsearch\
**Created:** [October 24, 2012, 1:53pm UTC](https://discuss.elastic.co/t/restrict-percolator-call-to-a-type/9458 "2012-10-24T13:53:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmaynier](https://avatars.discourse-cdn.com/v4/letter/j/3da27b/32.png) [@jmaynier](https://discuss.elastic.co/u/jmaynier)\
**Post date:** [October 24, 2012, 1:53pm UTC](https://discuss.elastic.co/t/restrict-percolator-call-to-a-type/9458/1 "2012-10-24T13:53:18Z")

</div>

As explained in the doc[http://www.elasticsearch.org/guide/reference/api/percolate.html](http://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.

--

---

<div class="post-metadata">

**Author:** ![radu\_gheorghe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/radu_gheorghe/32/556_2.png) [@radu\_gheorghe](https://discuss.elastic.co/u/radu_gheorghe)\
**Post date:** [October 24, 2012, 8:11pm UTC](https://discuss.elastic.co/t/restrict-percolator-call-to-a-type/9458/2 "2012-10-24T20:11:30Z")

</div>

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/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene

On Wed, Oct 24, 2012 at 4:53 PM, Jecom [jmaynier@eco2market.com](mailto: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.
> 
> --

--

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 3:07am UTC](https://discuss.elastic.co/t/restrict-percolator-call-to-a-type/9458/3 "2017-07-06T03:07:21Z")

</div>


