Confused as to what works - Percolator

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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/a5504b7a-ec47-4e6d-91bd-cbdb65411b5b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/6b0e623b-1239-44ac-870b-ab781511364a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Did you try with "site_id":"1" instead of 1?

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

Le 10 mai 2014 à 17:09, Glenn Jacobs 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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/6b0e623b-1239-44ac-870b-ab781511364a%40googlegroups.com.
For more options, visit 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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/26D6554A-F87D-4DE2-9277-9DCE0F0961EB%40pilato.fr.
For more options, visit https://groups.google.com/d/optout.

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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAPt3XKT_EpQO3PnH-MACPOCQYWMw9oeWnQWhOQDybc1JQ2y3TA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Many thanks for your replies, I’m a little hungover today :slight_smile: 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 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.
To unsubscribe from this group and all its topics, send an email to
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.

For more options, visit 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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CANx%3DypTNz%2B2v%3DoSzrHShvY3gwYcjhE4SCSji6DpA373LiWUkQw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/3fcc0988-dbd9-4ad5-8bd9-aa87ba39f7af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

On 3 September 2014 23:56, Glenn Jacobs 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.
To unsubscribe from this group and all its topics, send an email to
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.

For more options, visit 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.
To view this discussion on the web visit 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.