Geo_distance filter, multiple types


(Gábor Suhai) #1

Hi everyone,

I have one index with multiple types, each type has a different mapping,
but they share a common geo_point field called location.
How can I query across all types with a geo_distance filter?

Here's a sample query:

curl -XGET http://localhost:9200/myindex/_all/_search -d '
{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"geo_distance": {
"location": {
"lat": 50,
"lon": 50
},
"distance": "1km"
}
}
}
}
}'

It fails to find the location field (QueryParsingException[[myindex] failed
to find geo_point field [location]]; }]").
If I specify a type in the URL
(http://localhost:9200/myindex/mytype/_search) then it works, but if I
specify a type in the geo_distance filter (mytype.location) and leave the
URL as above it finds nothing.

Thanks
Gábor


(Shay Banon) #2

Can you try without the _all option, just myindex/_search? Which version are you using?

On Wednesday, February 15, 2012 at 2:38 PM, Gábor Suhai wrote:

Hi everyone,

I have one index with multiple types, each type has a different mapping, but they share a common geo_point field called location.
How can I query across all types with a geo_distance filter?

Here's a sample query:

curl -XGET http://localhost:9200/myindex/_all/_search -d '
{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"geo_distance": {
"location": {
"lat": 50,
"lon": 50
},
"distance": "1km"
}
}
}
}
}'

It fails to find the location field (QueryParsingException[[myindex] failed to find geo_point field [location]]; }]").
If I specify a type in the URL (http://localhost:9200/myindex/mytype/_search) then it works, but if I specify a type in the geo_distance filter (mytype.location) and leave the URL as above it finds nothing.

Thanks
Gábor


(Gábor Suhai) #3

Thanks Shay, it's working this way. It is version 0.18.7.


(Shay Banon) #4

Great. I just pushed a fix to the bug in the next 0.19.

On Wednesday, February 15, 2012 at 3:42 PM, Gábor Suhai wrote:

Thanks Shay, it's working this way. It is version 0.18.7.


(system) #5