首页 > 解决方案 > 尝试在 Elasticsearch 中为 py-image-dedup 定义索引

问题描述

我正在尝试让 py-image-dedup 工作(https://github.com/markusressel/py-image-dedup),这需要在 elasticsearch 中构建索引。到目前为止一切顺利,所有用于 py-image-dedup 和 brew install elasticsearch 的 python 代码都已安装并与 elasticsearch 服务器一起在本地主机地址 127.0.0.1:9200 上愉快地工作

所以现在我尝试建立索引。说明说

curl -X PUT "127.0.0.1:9200/images?pretty" -H "Content-Type: application/json" -d "
{
  \"mappings\": {
    \"image\": {
      \"properties\": {
        \"path\": {
          \"type\": \"keyword\",
          \"ignore_above\": 256
        }
      }
    }
  }
}

据我所知,这显然在末尾缺少一个 " 并且在任何变体中都不起作用。

我试试

curl -X PUT "127.0.0.1:9200/images?pretty"  -H "Content-Type: application/json" -d "{\"mappings\":{\"image\":{\"properties\":{\"path\":{\"type\":\"keyword\",\"ignore_above\":256}}}}} "


这看起来很明智,但得到

{
  "error" : {
    "root_cause" : [
      {
        "type" : "mapper_parsing_exception",
        "reason" : "Root mapping definition has unsupported parameters:  [image : {properties={path={ignore_above=256, type=keyword}}}]"
      }
    ],
    "type" : "mapper_parsing_exception",
    "reason" : "Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters:  [image : {properties={path={ignore_above=256, type=keyword}}}]",
    "caused_by" : {
      "type" : "mapper_parsing_exception",
      "reason" : "Root mapping definition has unsupported parameters:  [image : {properties={path={ignore_above=256, type=keyword}}}]"
    }
  },
  "status" : 400
}

并且无法为我的生活看到为什么索引没有正确构建。感谢帮助。

标签: elasticsearch

解决方案


您正在尝试使用已被弃用的类型:https ://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html

image请从您的映射定义中删除该类型。

curl -X PUT "127.0.0.1:9200/images?pretty" -H "Content-Type: application/json" -d "
{
  \"mappings\": {
    \"properties\": {
      \"path\": {
        \"type\": \"keyword\",
        \"ignore_above\": 256
      }
    }
  }
}

推荐阅读