【问题标题】:How to use dot notation in geo percolator如何在地理渗滤器中使用点符号
【发布时间】:2024-01-17 02:15:01
【问题描述】:

我使用 Elasticsearch 2.2.1 搜索与特定地理位置(在边界框内)相关的文档。我想创建一个过滤器,我可以用它来检查新文档是否与现有查询相关。

如果我将 percolator 放入包含文档的索引中,这会很好,但由于此 document 中提到的问题和提到的解决方法 here 我需要将 percolate 查询放入专用的 percolator 索引中。

当我尝试将过滤器放入该索引时:

PUT /mypercindex/.percolator/1
  {"query": {"filtered": {"filter":
    {"bool":
        {"should":
            [
                {"geo_bounding_box":
                    {"location.coordinates":
                        {"bottom_right":
                            {"lat":50.0,"lon":8.0}
                        ,"top_left":
                            {"lat":54.0,"lon":3.0}
                        }
                    }
                }
            ]
        }
    }
}}}

我收到一条错误消息:

名称为[location.coordinates]的字段,字段解析严格,找不到字段映射

在 percolator 文档中是 mentioned,如果是专用的 percolator 索引,您需要:

确保来自普通索引的映射也可用于渗透索引

这可能会导致我的问题,但我找不到有关如何使一个索引的映射在另一个索引中可用的文档。我尝试添加与我的文档索引具有相同映射的专用渗透器索引,但是当我这样做时,我仍然收到相同的错误消息。

我的文档索引的映射类似于:

{"my_mapping": {
  "dynamic":"strict",
  "properties":{
    "body":{
        "properties":{
            "author":{
                "type":"string",
                "index":"not_analyzed"
            },
            "hashtags":{
                "type":"string",
                "index":"not_analyzed"
            },
            "language":{
                "type":"string",
                "index":"not_analyzed"
            }
            ,"text":{
                "type":"string",
                "analyzer":"stopwords"
            },
            "title":{
                "type":"string",
                "analyzer":"stopwords"
            }
        }
    },
    "location":{
        "properties":{
            "coordinates":{
                "type":"geo_point"
            },
            "names":{
                "type":"string",
                "analyzer":"standard"
            }
        }
    }
  }
}}

任何帮助将不胜感激!

【问题讨论】:

    标签: elasticsearch geolocation


    【解决方案1】:

    .percolator 映射添加到映射中,例如mentioned in the Github issue that addresses this workaround,为我解决了这个问题:

    ".percolator": {
      "dynamic": true,
      "properties": {
        "id": {
          "type": "integer"
        }
      }
    }
    

    【讨论】:

      最近更新 更多