I'm trying to filter against a geo_point
(geo_coordinates) which is nested in an object (Location), which is nested in an array in the queried object (MyObject).
The problem is that the mapping for the object MyObject does not see the geo_coordinates field as a geo_point:
// Index mapping for object MyObject
"myobjects": {
"mappings": {
"myobject": {
"properties": {
"locations": {
"type": "nested",
"include_in_parent": true,
"properties": {
"geo_coordinates": {
"properties": {
"lat": { "type": "double" },
"lon": { "type": "double" }
}
},
}
[...]
// Index mapping for object Location
"locations": {
"mappings": {
"location": {
"properties": {
"geo_coordinates": {
"type": "geo_point"
},
}
}
}
The mongoose object MyObject looks like this:
var MyObjectSchema = new Schema(
[...]
locations: {
type: [{ type: Schema.Types.ObjectId, ref: 'Location', es_schema: LocationSchema.schema}],
es_type: 'nested',
es_include_in_parent: true
},
[...]
)
The mongoose object Location looks like this:
var LocationSchema = new Schema(
[...]
geo_coordinates: {
type: {
geo_point: {
type: String,
es_type: 'geo_point',
es_lat_lon: true
},
lat: {type: Number, default: 0},
lon: {type: Number, default: 0}
},
es_type: 'geo_point'
}
[...]
);
My query looks like this:
// POST http://ES-endpoint/locations/_search
{
"query": {
"filtered" : {
"query": {
"match_all" : {}
},
"filter" : {
"geo_distance" : {
"distance" : "20000km",
"locations.geo_coordinates" : {
"lat" : 40,
"lon" : -70
}}}}}}
I must miss something, but what ?
PS: When exploring the indexes with Kibana, both objects have the same data for geo_location:
"geo_coordinates": {
"lat": x.xxxx,
"lon": y.yyy
}