【发布时间】:2014-03-06 10:55:17
【问题描述】:
我将Geo Distance Filter 与ElasticSearch 一起使用,无论我搜索什么距离,elasticsearch 0.90.11 都会返回零结果。
这是我所做的:首先,使用地理映射删除/创建一个新索引:
curl -XDELETE 'http://localhost:9200/photos'
curl -XPOST 'http://localhost:9200/photos' -d '
{
"mappings": {
"pin" : {
"properties" : {
"location" : {
"type" : "geo_point"
}
}
}
}
}
'
然后,添加一个文档:
curl -XPOST 'http://localhost:9200/photos/photo?pretty=1' -d '
{
"pin" : {
"location" : {
"lat" : 46.8,
"lon" : -71.2
}
},
"file" : "IMG_2115.JPG"
}
'
然后搜索:
curl -XGET 'http://localhost:9200/photos/_search?pretty=1&size=20' -d '
{
"query" : {
"match_all" : {}
},
"filter" : {
"geo_distance" : {
"distance" : "10km",
"pin.location" : {
"lat" : "46.8",
"lon" : "-71.2"
}
}
}
}
'
但搜索结果为零:
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}
有人知道为什么在半径范围内找不到文档吗?作为一个有趣的附注,上面引用的文档中描述的同时具有“查询”和“过滤器”作为子字段的“过滤”语法似乎根本不再起作用,现在似乎需要“查询”和“过滤器”在 json 查询的顶层。
任何帮助表示赞赏...
【问题讨论】:
标签: elasticsearch geo