# Trying to filter percolators, what am I doing wrong?

**URL:** <https://discuss.elastic.co/t/trying-to-filter-percolators-what-am-i-doing-wrong/7592>\
**Category:** Elasticsearch\
**Created:** [May 8, 2012, 6:10am UTC](https://discuss.elastic.co/t/trying-to-filter-percolators-what-am-i-doing-wrong/7592 "2012-05-08T06:10:17Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brett\_Anderson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brett_anderson/32/2555_2.png) [@Brett\_Anderson](https://discuss.elastic.co/u/Brett_Anderson)\
**Post date:** [May 8, 2012, 6:10am UTC](https://discuss.elastic.co/t/trying-to-filter-percolators-what-am-i-doing-wrong/7592/1 "2012-05-08T06:10:17Z")

</div>

I interpreted the percolator filter feature shown here [http://www.elasticsearch.org/guide/reference/api/percolate.html](http://www.elasticsearch.org/guide/reference/api/percolate.html)to  
mean that I could give percolators additional terms and then supply a query  
on those terms when percolating a document. This would first retrieve the  
subset of percolators that match the query, then percolate the document  
against that set. In my example [https://gist.github.com/2632887](https://gist.github.com/2632887) I create  
two percolators with a term called 'color', set to 'blue' for both. Each  
percolator has a query on a field called 'sport', one for the word  
'sailing', the other for the word 'tennis'. If I percolate a document with  
the sport field set to 'tennis', ES correctly returns a match on the tennis  
percolator alone. If however I percolate the same doc with an additional  
query to filter the percolators, a match for both percolators is returned.  
I've found this to occur in both 0.19.2 and 0.19.3. Is my understanding of  
this feature correct? If so what is wrong with my application of it, or is  
this a bug?

As mentioned above, the example: [https://gist.github.com/2632887](https://gist.github.com/2632887),

Thanks,  
LJ.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [May 8, 2012, 1:47pm UTC](https://discuss.elastic.co/t/trying-to-filter-percolators-what-am-i-doing-wrong/7592/2 "2012-05-08T13:47:53Z")

</div>

Its a bug..., opened an issue:  
[Percolator: Filtering percolators based on a query can cause wrong matches to be returned · Issue #1925 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1925), will be fixed  
shortly on both 0.19 branch and master.

On Tue, May 8, 2012 at 9:10 AM, Laser Jesus [brett.anderson.ftw@gmail.com](mailto:brett.anderson.ftw@gmail.com)wrote:

> I interpreted the percolator filter feature shown here [http://www.elasticsearch.org/guide/reference/api/percolate.html](http://www.elasticsearch.org/guide/reference/api/percolate.html)to  
> mean that I could give percolators additional terms and then supply a query  
> on those terms when percolating a document. This would first retrieve the  
> subset of percolators that match the query, then percolate the document  
> against that set. In my example [https://gist.github.com/2632887](https://gist.github.com/2632887) I  
> create two percolators with a term called 'color', set to 'blue' for both.  
> Each percolator has a query on a field called 'sport', one for the word  
> 'sailing', the other for the word 'tennis'. If I percolate a document with  
> the sport field set to 'tennis', ES correctly returns a match on the tennis  
> percolator alone. If however I percolate the same doc with an additional  
> query to filter the percolators, a match for both percolators is returned.  
> I've found this to occur in both 0.19.2 and 0.19.3. Is my understanding of  
> this feature correct? If so what is wrong with my application of it, or is  
> this a bug?
> 
> As mentioned above, the example: [Elasticsearch setup to demonstrate filtering percolators · GitHub](https://gist.github.com/2632887),
> 
> Thanks,  
> LJ.

---

<div class="post-metadata">

**Author:** ![Brett\_Anderson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brett_anderson/32/2555_2.png) [@Brett\_Anderson](https://discuss.elastic.co/u/Brett_Anderson)\
**Post date:** [May 9, 2012, 6:11am UTC](https://discuss.elastic.co/t/trying-to-filter-percolators-what-am-i-doing-wrong/7592/3 "2012-05-09T06:11:15Z")

</div>

> Thanks for the quick solution. Just retried with the latest for 0.19.4 and  
> it's working nicely.

---

<div class="post-metadata">

**Author:** ![Brett\_Anderson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brett_anderson/32/2555_2.png) [@Brett\_Anderson](https://discuss.elastic.co/u/Brett_Anderson)\
**Post date:** [May 16, 2012, 4:34am UTC](https://discuss.elastic.co/t/trying-to-filter-percolators-what-am-i-doing-wrong/7592/4 "2012-05-16T04:34:14Z")

</div>

> I'm having some more issues with this bug under a more constrained  
> environment. If you run my gist here [https://gist.github.com/2632887](https://gist.github.com/2632887), except  
> the last line which deletes the index, but making sure all the lines before  
> it are executed in a single time interval, on a fresh ES 19.4 instance with  
> no data or logs folders, you get a strange result. The last percolation  
> request, which uses percolator filtering, does not match. If you re-run it  
> a second later it matches correctly. If you delete the index and then run  
> the script again, in a single time interval, the last percolator _does_  
> match. I stumbled on this one when some of my unit tests worked when I had  
> a break-point, but failed without it...

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [May 16, 2012, 10:06pm UTC](https://discuss.elastic.co/t/trying-to-filter-percolators-what-am-i-doing-wrong/7592/5 "2012-05-16T22:06:24Z")

</div>

What happens if you add a POST to refresh the \_percolator index after you  
registered the queries? Does that solve it?

On Wed, May 16, 2012 at 7:34 AM, Laser Jesus  
[brett.anderson.ftw@gmail.com](mailto:brett.anderson.ftw@gmail.com)wrote:

> I'm having some more issues with this bug under a more constrained
> 
> > environment. If you run my gist here [https://gist.github.com/2632887](https://gist.github.com/2632887), except  
> > the last line which deletes the index, but making sure all the lines before  
> > it are executed in a single time interval, on a fresh ES 19.4 instance with  
> > no data or logs folders, you get a strange result. The last percolation  
> > request, which uses percolator filtering, does not match. If you re-run it  
> > a second later it matches correctly. If you delete the index and then run  
> > the script again, in a single time interval, the last percolator _does_  
> > match. I stumbled on this one when some of my unit tests worked when I had  
> > a break-point, but failed without it...

---

<div class="post-metadata">

**Author:** ![Brett\_Anderson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brett_anderson/32/2555_2.png) [@Brett\_Anderson](https://discuss.elastic.co/u/Brett_Anderson)\
**Post date:** [May 17, 2012, 1:04am UTC](https://discuss.elastic.co/t/trying-to-filter-percolators-what-am-i-doing-wrong/7592/6 "2012-05-17T01:04:21Z")

</div>

> Do you mean this:

curl -XPOST localhost:9200/\_percolator/\_flush

Because yes, that fixed it 🙂

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [May 20, 2012, 7:12pm UTC](https://discuss.elastic.co/t/trying-to-filter-percolators-what-am-i-doing-wrong/7592/7 "2012-05-20T19:12:05Z")

</div>

No, actually, flush is not really relevant, refresh is the one we care  
about.

On Thu, May 17, 2012 at 3:04 AM, Laser Jesus  
[brett.anderson.ftw@gmail.com](mailto:brett.anderson.ftw@gmail.com)wrote:

> Do you mean this:
> 
> curl -XPOST localhost:9200/\_percolator/\_flush
> 
> Because yes, that fixed it 🙂

---

<div class="post-metadata">

**Author:** ![Brett\_Anderson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brett_anderson/32/2555_2.png) [@Brett\_Anderson](https://discuss.elastic.co/u/Brett_Anderson)\
**Post date:** [May 21, 2012, 12:44am UTC](https://discuss.elastic.co/t/trying-to-filter-percolators-what-am-i-doing-wrong/7592/8 "2012-05-21T00:44:47Z")

</div>

Ok, just changed it to refresh and all unit tests still working. Thanks.

---

<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:27am UTC](https://discuss.elastic.co/t/trying-to-filter-percolators-what-am-i-doing-wrong/7592/9 "2017-07-06T03:27:53Z")

</div>


