0
我正在尝试搜索具有给定纬度/经度的多边形相交的文档。这里是我的映射在geo_shape查询中查找多边形elasticsearch
{
index:"domains",
type:"land",
body:{
properties:{
landId:{
type:"integer"
},
name:{
type:"string"
},
location:{
type:"geo_shape"
}
}
}
}
这里是我已经索引的文档
{
landId:1,
name:"My Test location ",
location:{
type:"polygon",
coordinates: [[
[-90.4321575,41.4854342],
[-90.4318142,41.469615],
[-90.4138756,41.4697436],
[-90.4139614,41.4855628],
[-90.4321575,41.4854342]
]]
}
}
这里是我的查询
var query = {
"index":"domains",
"type":"lands",
"match_all":{},
"geo_shape": {
"location": {
"relation": "intersects",
"shape": {
"type": "point",
"coordinates":[-90.4244328,41.4794542]
}
}
}
}
return esClient.search(query).then(function(resp){
console.log("**** GOT RESPONSE from Search ****")
console.log(resp.hits);
return resp.hits.hits[0]._source;
}),function (err) {
console.trace(err.message);
}
;
如果我指定索引/类型查询我没有得到任何结果,如果我没有指定,那么无论我添加的过滤器如何,我都会获得所有文档。
感谢瓦尔,我试过了,但仍然没有结果。此外,如果我没有指定任何索引或类型并仅提供查询,那么我得到的一切对我来说也不会有什么困惑。 – user3248984
我修改了包含几个拼写错误的查询,请再试一次。 – Val
谢谢,它的工作原理...感谢您的帮助,所以缺少的部分是将查询放在“身体”标签? – user3248984