# Confused as to what works - Percolator

**URL:** <https://discuss.elastic.co/t/confused-as-to-what-works-percolator/17444>\
**Category:** Elasticsearch\
**Created:** [May 10, 2014, 3:00pm UTC](https://discuss.elastic.co/t/confused-as-to-what-works-percolator/17444 "2014-05-10T15:00:40Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Glenn\_Jacobs](https://avatars.discourse-cdn.com/v4/letter/g/e495f1/32.png) [@Glenn\_Jacobs](https://discuss.elastic.co/u/Glenn_Jacobs)\
**Post date:** [May 10, 2014, 3:00pm UTC](https://discuss.elastic.co/t/confused-as-to-what-works-percolator/17444/1 "2014-05-10T15:00:40Z")

</div>

Hi there

We've been using Elasticsearch for our main site search and it works a  
treat using geo-location searches and filters etc. But I can't seem to make  
it play nicely with percolator queries.

Here's an example of what we're trying to do...

This is an example document: -

{  
"\_id": 156742,  
"\_type": "",  
"\_index": "",  
"\_source": {  
"id": "156742",  
"thumb\_id": null,  
"thumb\_format": null,  
"advert\_title": "Lovely rooms to rent in Writtle, Chelmsford",  
"advert\_desc": "We have two lovely rooms. We have two lovely rooms. We have two lovely rooms. We have two lovely rooms. We have two lovely rooms. We have two lovely rooms. We have two lovely rooms. We have two lovely rooms. We have two lovely rooms. We have two lovely rooms. We have two lovely rooms. We have two lovely rooms. We have two lovely rooms. We have two lovely rooms. We have two lovely rooms. We have two lovely rooms. We have two lovely rooms. We have two lovely rooms. We have two lovely rooms.",  
"slug": "536E1ED90F4AD",  
"location": "51.7285690,0.4227900",  
"utilities": "0.00",  
"locality": "Writtle",  
"town": "Chelmsford",  
"county": "Essex",  
"postcode": "CM1 3LF",  
"outcode": "CM1",  
"created\_at": "2014-05-10 13:43:05",  
"no\_rooms": 2,  
"wanted\_gender": "0",  
"wanted\_orientation": "0",  
"couples\_accepted": "2",  
"jsa\_accepted": "2",  
"students\_accepted": "2",  
"smokers\_accepted": "2",  
"pets\_allowed": "1",  
"parking\_avail": "2",  
"whole\_property": "1",  
"wanted\_religion": "0",  
"featured": 0,  
"bold": 0,  
"site\_id": "1",  
"moderated": "0",  
"rooms": [  
{  
"rent\_pcm": "400.00",  
"rent": "400.00",  
"rent\_type": "1",  
"deposit": "400.00",  
"room\_size": "2",  
"furnished": "2",  
"bathroom": "1",  
"weekdays": "1",  
"avail\_from": "2014-05-10"  
},  
{  
"rent\_pcm": "400.00",  
"rent": "400.00",  
"rent\_type": "1",  
"deposit": "400.00",  
"room\_size": "2",  
"furnished": "2",  
"bathroom": "1",  
"weekdays": "1",  
"avail\_from": "2014-05-10"  
}  
]  
}  
}

If I try this Percolator query I get a result

{  
"filtered": {  
"query": {  
"match\_all": {}  
},  
"filter": {  
"and": [  
{  
"geo\_distance": {  
"distance": "1miles",  
"location": "51.7272680,0.4194800"  
}  
}  
]  
}  
}  
}

However, as soon as I try to add additional filters, it stops returning the  
example document as a result, e.g.

{  
"filtered": {  
"query": {  
"match\_all": {}  
},  
"filter": {  
"and": [  
{  
"geo\_distance": {  
"distance": "1miles",  
"location": "51.7272680,0.4194800"  
}  
},  
{  
"or": [  
{  
"term": {  
"site\_id": 1  
}  
},  
{  
"and": [  
{  
"not": {  
"filter": {  
"term": {  
"site\_id": 1  
}  
}  
}  
},  
{  
"term": {  
"bold": 1  
}  
}  
]  
}  
]  
}  
]  
}  
}  
}

Is anyone able to shed any light on this for me? I haven't a clue why it's  
not working!

Thanks

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/a5504b7a-ec47-4e6d-91bd-cbdb65411b5b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a5504b7a-ec47-4e6d-91bd-cbdb65411b5b%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Glenn\_Jacobs](https://avatars.discourse-cdn.com/v4/letter/g/e495f1/32.png) [@Glenn\_Jacobs](https://discuss.elastic.co/u/Glenn_Jacobs)\
**Post date:** [May 10, 2014, 3:09pm UTC](https://discuss.elastic.co/t/confused-as-to-what-works-percolator/17444/2 "2014-05-10T15:09:32Z")

</div>

Even this simple example doesn't work...

{  
"filtered": {  
"query": {  
"match\_all": {}  
},  
"filter": {  
"and": [  
{  
"geo\_distance": {  
"distance": "1miles",  
"location": "51.7272680,0.4194800"  
}  
},  
{  
"term": {  
"site\_id": 1  
}  
}  
]  
}  
}  
}

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/6b0e623b-1239-44ac-870b-ab781511364a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6b0e623b-1239-44ac-870b-ab781511364a%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 10, 2014, 4:18pm UTC](https://discuss.elastic.co/t/confused-as-to-what-works-percolator/17444/3 "2014-05-10T16:18:09Z")

</div>

Did you try with "site\_id":"1" instead of 1?

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

> Le 10 mai 2014 à 17:09, Glenn Jacobs [glennalanjacobs@gmail.com](mailto:glennalanjacobs@gmail.com) a écrit :
> 
> Even this simple example doesn't work...
> 
> {  
> "filtered": {  
> "query": {  
> "match\_all": {}  
> },  
> "filter": {  
> "and": [  
> {  
> "geo\_distance": {  
> "distance": "1miles",  
> "location": "51.7272680,0.4194800"  
> }  
> },  
> {  
> "term": {  
> "site\_id": 1  
> }  
> }  
> ]  
> }  
> }  
> }
> 
> --  
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/6b0e623b-1239-44ac-870b-ab781511364a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6b0e623b-1239-44ac-870b-ab781511364a%40googlegroups.com).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/26D6554A-F87D-4DE2-9277-9DCE0F0961EB%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/26D6554A-F87D-4DE2-9277-9DCE0F0961EB%40pilato.fr).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [May 10, 2014, 4:39pm UTC](https://discuss.elastic.co/t/confused-as-to-what-works-percolator/17444/4 "2014-05-10T16:39:03Z")

</div>

It helps to provide the exact steps that you were trying, otherwise we are  
left to guess. I tried your example and it worked, but then I probably  
did it in a slightly different way.

I think the likeliest problem is that you are creating the percolator  
queries before you index a document or setup the mapping? That means that  
(eg) the site\_id clause defaults to using a string query, because it  
doesn't have a mapping to refer to to figure out that it is a long field.

If you setup the mapping before registering the percolation queries, then  
things should work correctly.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAPt3XKT\_EpQO3PnH-MACPOCQYWMw9oeWnQWhOQDybc1JQ2y3TA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPt3XKT_EpQO3PnH-MACPOCQYWMw9oeWnQWhOQDybc1JQ2y3TA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Glenn\_Jacobs](https://avatars.discourse-cdn.com/v4/letter/g/e495f1/32.png) [@Glenn\_Jacobs](https://discuss.elastic.co/u/Glenn_Jacobs)\
**Post date:** [May 11, 2014, 6:10pm UTC](https://discuss.elastic.co/t/confused-as-to-what-works-percolator/17444/5 "2014-05-11T18:10:49Z")

</div>

Many thanks for your replies, I’m a little hungover today 🙂 so I’ll  
take a proper look at your suggestions on Monday and see how I go.

Really hope I can get it working as it would be awesome for our app.

On 10 May 2014 17:39, Clinton Gormley [clint@traveljury.com](mailto:clint@traveljury.com) wrote:

> It helps to provide the exact steps that you were trying, otherwise we are  
> left to guess. I tried your example and it worked, but then I probably did  
> it in a slightly different way.
> 
> I think the likeliest problem is that you are creating the percolator  
> queries before you index a document or setup the mapping? That means that  
> (eg) the site\_id clause defaults to using a string query, because it doesn't  
> have a mapping to refer to to figure out that it is a long field.
> 
> If you setup the mapping before registering the percolation queries, then  
> things should work correctly.
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/-kzy9LiNZa4/unsubscribe](https://groups.google.com/d/topic/elasticsearch/-kzy9LiNZa4/unsubscribe).  
> To unsubscribe from this group and all its topics, send an email to  
> [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CAPt3XKT\_EpQO3PnH-MACPOCQYWMw9oeWnQWhOQDybc1JQ2y3TA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPt3XKT_EpQO3PnH-MACPOCQYWMw9oeWnQWhOQDybc1JQ2y3TA%40mail.gmail.com).
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CANx%3DypTNz%2B2v%3DoSzrHShvY3gwYcjhE4SCSji6DpA373LiWUkQw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CANx%3DypTNz%2B2v%3DoSzrHShvY3gwYcjhE4SCSji6DpA373LiWUkQw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Glenn\_Jacobs](https://avatars.discourse-cdn.com/v4/letter/g/e495f1/32.png) [@Glenn\_Jacobs](https://discuss.elastic.co/u/Glenn_Jacobs)\
**Post date:** [September 3, 2014, 10:56pm UTC](https://discuss.elastic.co/t/confused-as-to-what-works-percolator/17444/6 "2014-09-03T22:56:41Z")

</div>

OK I've just come back to this (4 months later!) and I'm still struggling.

I've created the index, added suitable mappings, registered percolation  
queries and then run a percolation match on a document.

Still it produces results with just the geo\_distance filter, but when I add  
the "site\_id" filter it stops returning results (site\_id is mapped as an  
integer).

Am I doing something fundamentally wrong? Should I be creating mappings on  
the percolator?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/3fcc0988-dbd9-4ad5-8bd9-aa87ba39f7af%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3fcc0988-dbd9-4ad5-8bd9-aa87ba39f7af%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Glenn\_Jacobs](https://avatars.discourse-cdn.com/v4/letter/g/e495f1/32.png) [@Glenn\_Jacobs](https://discuss.elastic.co/u/Glenn_Jacobs)\
**Post date:** [September 4, 2014, 9:47am UTC](https://discuss.elastic.co/t/confused-as-to-what-works-percolator/17444/7 "2014-09-04T09:47:08Z")

</div>

Turns out if I percolate using a document which is already indexed it  
works! Problem solved 🙂

On 3 September 2014 23:56, Glenn Jacobs [glennalanjacobs@gmail.com](mailto:glennalanjacobs@gmail.com) wrote:

> OK I've just come back to this (4 months later!) and I'm still struggling.
> 
> I've created the index, added suitable mappings, registered percolation  
> queries and then run a percolation match on a document.
> 
> Still it produces results with just the geo\_distance filter, but when I add  
> the "site\_id" filter it stops returning results (site\_id is mapped as an  
> integer).
> 
> Am I doing something fundamentally wrong? Should I be creating mappings on  
> the percolator?
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/-kzy9LiNZa4/unsubscribe](https://groups.google.com/d/topic/elasticsearch/-kzy9LiNZa4/unsubscribe).  
> To unsubscribe from this group and all its topics, send an email to  
> [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/3fcc0988-dbd9-4ad5-8bd9-aa87ba39f7af%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3fcc0988-dbd9-4ad5-8bd9-aa87ba39f7af%40googlegroups.com).
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CANx%3DypSch0AOo0oF%3DSPtvM%2Bp3kG0i5kBmhixg7ehN7HOgO5%3D\_g%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CANx%3DypSch0AOo0oF%3DSPtvM%2Bp3kG0i5kBmhixg7ehN7HOgO5%3D_g%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:04am UTC](https://discuss.elastic.co/t/confused-as-to-what-works-percolator/17444/8 "2017-07-06T01:04:26Z")

</div>


