【发布时间】:2015-09-29 02:49:19
【问题描述】:
在我的应用程序中,我使用的是 mongoosastic 。我创建了映射和架构,但是当我看到映射结果时,它会将位置 geo_point 属性更改为对象类型,因此在我使用查询进行搜索时它可能会给我错误:
错误:嵌套:QueryParsingException[[userprofiles] 未能找到 geo_point 字段 [位置]]; }]"
我提前查询休息客户端
创建映射:
"mappings": {
"userprofile": {
"properties": {
"address": {
"type": "string"
},
"timing": {
"type": "object",
"properties": {
"open": {
"type": "string"
},
"close": {
"type": "string"
}
},
"location": {
"type": "geo_point"
}
}
}
}
}
用户架构
var UserProfileSchema = new Schema({
userId: String,
username: String,
address: {
type: String,
es_indexed: true
},
number: {
type: Number,
es_indexed: true
},
location: {
lat: Number,
lon: Number
},
timing: {
open: String,
close: String
}
});
搜索查询:
{
"query": {
"filtered" : {
"query" : {
"match_all" : {}
},
"filter" : {
"geo_distance" : {
"distance" : "20km",
"location" : {
"lat" : 37.9174,
"lon" : -122.3050
}
}
}
}
}
}
【问题讨论】:
标签: node.js elasticsearch mongoosastic