如何对Elasticsearch中的多个位置字段进行地理距离过滤
我对每个文档有任意的位置数据点(最多80个)。我想对这些位置执行地理距离过滤器。elasticsearch文件声称:如何对Elasticsearch中的多个位置字段进行地理距离过滤,search,search-engine,elasticsearch,django-haystack,Search,Search Engine,elasticsearch,Django Haystack,我对每个文档有任意的位置数据点(最多80个)。我想对这些位置执行地理距离过滤器。elasticsearch文件声称: The geo_distance filter can work with multiple locations / points per document. Once a single location / point matches the filter, the document will be included in the filter. 如何做到这一点还不
The geo_distance filter can work with multiple locations / points per document.
Once a single location / point matches the filter, the document will be included in the filter.
如何做到这一点还不清楚。我假设您必须提前定义位置的#,以便您的索引文档看起来包含以下嵌套字段:
{
"pin" : {
"location" : {
"lat" : 40.12,
"lon" : -71.34
}
}
}
{
"alt_pin" : {
"location" : {
"lat" : 41.12,
"lon" : -72.34
}
}
}
我假设您会以某种方式根据pin.location和alt_pin.location进行过滤
如果我有任意数量的位置(pin1、pin2、pin3等),该怎么办?我可以这样做吗:
"pin" : {
"locations" : [{
"lat" : 41.12,
"lon" : -72.34
}, {
"lat" : 41.12,
"lon" : -72.34
}]
}
}
你会在那工作上做些改变吗?可能使用geo_散列而不是lat/lng坐标?多个
位置
值可以表示为位置
字段的数组。试试这个:
{
"pin": [
{
"location" :{
"lat": 40.12,
"lon": -71.34
}
},
{
"location" :{
"lat": 41.12,
"lon": -72.34
}
}
]
}