I am running into a problem with geo_distance sorting on nested documents
containing geo_points and I am wondering if I am just going about it
incorrectly. Here is a simplified version of what I have:
curl -X DELETE http://localhost:9200/venue
curl -X POST http://localhost:9200/venue -d '
{
"mappings": {
"venue": {
"properties": {
"name": {
"type": "string"
},
"locations": {
"type": "nested",
"properties": {
"geo": {
"type": "geo_point"
},
"city": {
"type": "string"
}
}
}
}
}
}
}
'
curl -X POST "http://localhost:9200/venue/venue/" -d
'{"type":"venue","name":"One","locations":[{"city":"Chicago","geo":[40.1,-70.1]}]}'
curl -X POST "http://localhost:9200/venue/venue/" -d
'{"type":"venue","name":"Two","locations":[{"city":"New
York","geo":[10.1,-7.1]},{"city":"Los Angeles","geo":[140.1,-120.1]}]}'
curl -X POST "http://localhost:9200/venue/venue/" -d
'{"type":"venue","name":"Three","locations":[{"city":"Canberra","geo":[40.2,-70.2]}]}'
curl -X POST "http://localhost:9200/venue/venue/" -d
'{"type":"venue","name":"Four","locations":[{"city":"Atlanta","geo":[5.1,5.1]}]}'
curl -X POST "http://localhost:9200/venue/_refresh"
Filtering works as expected
curl -X GET 'http://localhost:9200/venue/_search?pretty' -d '
{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"nested": {
"path": "locations",
"filter": {
"geo_distance": {
"distance": "60km",
"geo": {
"lat": -70.00331,
"lon": 40.0834715
}
}
}
}
}
}
}
}
'
This does not work as I'd expected. I'm just looking for the venues
closest
curl -X GET 'http://localhost:9200/venue/_search?pretty' -d '
{
"track_scores": true,
"query": {
"match_all": {}
},
"sort": [
{
"_geo_distance": {
"locations.geo": [
5,
5
]
}
}
]
}
'
#If I remove the 'nested' specification from the mapping, it does work as
expected:
curl -X DELETE http://localhost:9200/venue
curl -X POST http://localhost:9200/venue -d '
{
"mappings": {
"venue": {
"properties": {
"name": {
"type": "string"
},
"locations": {
"properties": {
"geo": {
"type": "geo_point"
},
"city": {
"type": "string"
}
}
}
}
}
}
}
'
Is there something special I need to do to get geo_distance sorting to work
with nested documents?
--
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.
For more options, visit https://groups.google.com/groups/opt_out.