3
쿼리 된 개체 (MyObject)의 배열에 중첩 된 개체 (위치)에 중첩 된 geo_point
(geo_coordinates)에 대해 필터링하려고합니다.중첩 된 개체의 배열에서 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"
},
}
}
}
몽구스 대상을 MyObject는 다음과 같습니다 :
var MyObjectSchema = new Schema(
[...]
locations: {
type: [{ type: Schema.Types.ObjectId, ref: 'Location', es_schema: LocationSchema.schema}],
es_type: 'nested',
es_include_in_parent: true
},
[...]
)
몽구스 객체의 위치처럼 보이는
문제는 개체 MyObject에 대한 매핑이 geo_point로 geo_coordinates 필드가 표시되지 않는다는 것입니다 이 :
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'
}
[...]
);
내 쿼리는 다음과 같습니다
,// POST http://ES-endpoint/locations/_search
{
"query": {
"filtered" : {
"query": {
"match_all" : {}
},
"filter" : {
"geo_distance" : {
"distance" : "20000km",
"locations.geo_coordinates" : {
"lat" : 40,
"lon" : -70
}}}}}}
나는 무엇인가 놓쳐 야한다. 그러나 무엇?
PS : 키바와 인덱스를 탐색 할 때, 두 개체 geo_location 동일한 데이터를 가지고
"geo_coordinates": {
"lat": x.xxxx,
"lon": y.yyy
}