Elasticsearch - 根据其他文档geo_shape搜索带有geo_shape的文档



是否有一个选项可以在ElasticSearch中使用一个查询来执行搜索,如下所示:

  1. 获取 ID = 1 的文档
  2. 本文档有一个具有geo_shape映射的字段
  3. 从该字段中获取值
  4. 搜索geo_shape字段与 doc(id=1) geo_shape相交的其他文档
  5. 返回找到的文档

是的,您可以使用预先索引的形状来实现此目的。

POST /_search
{
"query": {
"bool": {
"must": {
"match_all": {}
},
"filter": {
"geo_shape": {
"your_shape_field": {
"indexed_shape": {
"id": "1",
"type": "your_type",
"index": "your_index",
"path": "shape"
},
"relation": "intersects"
}
}
}
}
}
}

此查询将返回your_shape_fieldid 为 1 的文档中shape字段相交的所有文档。

最新更新