I'm trying to sort by geo distance an index with nested geo point mapping.
Here is my simplified mapping :
'organizations' => [
'_doc' => [
'properties' => [
'locations' => [
'type' => 'nested',
'properties' => [
'point' => [
'type' => 'geo_point',
'ignore_malformed' => true
]
]
]
]
]
]
Here, each organizations can have several locations point.
Documents :
PUT /organizations ,
[
{
name: "A",
locations: [
{
point: {
lat: 1.5,
lon: 2
}
},
{
point: {
lat: 1,
lon: 0
}
}
]
},
{
name: "B",
locations: [
{
point: {
lat: 4.2,
lon: 3
}
}
]
},
{
name: "C",
locations: [
{
point: {
lat: 0.4,
lon: 1
}
}
]
}
];
Here is my query (PHP array):
[
"query" => [
"query_string" => [
"query" => "*"
]
]
"sort" => [
0 => [
"_geo_distance" => [
"locations.point" => "1, 0.1"
"order" => "asc"
"unit" => "km"
"nested_path" => "locations"
]
]
]
]
expected result :
1 => name : A
2 => name : C
3 => bame : B
I'd like to get resources ordered by geo_point (check each location, and then check if a location is close to the given lat / lon )
A
,C
,B
? If you want in asc order it should beC
,A
,B
? – ESCoder