我在弹性搜索中保存了一组地理位置,搜索结果如下:
{
"query" : {
"match_all" : {}
}
}
我得到了完整的结果,一切正常。 但是,一旦我开始将搜索限制到任何区域(即使它是-100,-100到100,100如下所示:
{
"query" : {
"filtered" : {
"query" : {
"match_all" : {}
},
"filter" : {
"geo_bounding_box" : {
"location" : {
"top_left" : "-100, -100",
"bottom_right" : "100, 100"
}
}
}
}
}
}
我得到的所有答案都是:
stdClass Object
(
[took] => 21
[timed_out] =>
[_shards] => stdClass Object
(
[total] => 4
[successful] => 4
[failed] => 0
)
[hits] => stdClass Object
(
[total] => 0
[max_score] =>
[hits] => Array
(
)
)
)
我已经没有关于如何解决这个问题的想法,所以,任何人都有任何有用的建议吗?
答案 0 :(得分:1)
你有没有尝试过:
"query": { match_all: {} },
"filter" : {
"geo_bounding_box" : {
"location" : {
"top_left" : "-100, -100",
"bottom_right" : "100, 100"
}
}
}
答案 1 :(得分:0)
我找到了解决方案,这就是我开始工作的方式:
{
"query" : {
"filtered" : {
"query" : {
"match_all" : {}
},
"filter" : {
"geo_polygon" : {
"location" : {
"points" : [
"10,10",
"20, 10",
"20, 20",
"10, 20"
]
}
}
}
}
}
}