我想用geo_distance query在多个位置上搜索(使用ES 7.3)。例如:
在柏林搜索+10公里
慕尼黑+10公里搜索
然后给我一个综合的结果。
基本上我在这里尝试了一下:
geo_distance上的数组不工作。我很想在这方面得到一些帮助:)
发布于 2019-09-30 10:31:06
搜索多个位置映射的一个简单示例:
PUT location
{
"mappings": {
"properties" : {
"pin" : {
"type" : "geo_point"
}
}
}
}数据:
[
{
"_index" : "location",
"_type" : "_doc",
"_id" : "rhn8f20BIb7c4jbYhr3Z",
"_score" : 1.0,
"_source" : {
"pin" : {
"lat" : 40.73,
"lon" : -74.1
}
}
},
{
"_index" : "location",
"_type" : "_doc",
"_id" : "rxn8f20BIb7c4jbYz709",
"_score" : 1.0,
"_source" : {
"pin" : {
"lat" : 40.717,
"lon" : -73.99
}
}
}
]查询:
GET location/_search
{
"query": {
"bool": {
"should": [ ---> multiple filters in should clause , either one of these has to be true
{
"geo_distance" : {
"distance" : "1km",
"pin" : {
"lat" : 40.73,
"lon" : -74.1
}
}
},
{
"geo_distance" : {
"distance" : "1km",
"pin" : {
"lat" : 40.717,
"lon" : -73.99
}
}
}
]
}
}
}https://stackoverflow.com/questions/58154471
复制相似问题