我正在获取QueryParsingException[[listings] failed to find geo_point field [location.coords]]; }]
,无法完全弄清楚原因。
我的查询
esClient.search({
index: 'listings',
body: {
query: {
filtered: {
query: {
match_all: {}
},
filter: {
geo_distance: {
distance: '10km',
'location.coords': {
lat: parseFloat(query.point.lat),
lon: parseFloat(query.point.lon)
}
}
}
}
}
}
}, function(err, response) {
if(err) return console.log(err);
console.log(response);
});
我的映射(如您所见-是的,我确实使用了geo_point类型)
body: {
properties: {
location: {
type: 'object',
properties: {
country: {
type: 'integer'
},
address: {
type: 'string'
},
suburb: {
type: 'string'
},
coords: {
type: 'geo_point',
precision: '3m'
}
}
}
}
}
编辑:
在查找http://localhost:9200/listings/_mapping/my-mapping之后,我注意到coords字段的经纬度设置为double-可能与此有关。
最佳答案
好的,事实证明这是由于我定义geo_point的精度(需要包装在fielddata属性中)而发生的,奇怪的是我使用的JS API没有引发任何我记得的错误:
正确:
coords: {
type: 'geo_point',
fielddata: {
format: 'compressed',
precision: '3m'
}
}
错误:
coords: {
type: 'geo_point',
precision: '3m'
}
}
瞧...
关于elasticsearch - QueryParsingException无法找到geo_point字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28856860/