首页 文章

索引映射时不支持Elasticsearch fielddata

提问于
浏览
1

我正在尝试通过Python在Elasticsearch中创建索引 . 我部署了一个本地ES实例,查询运行正常 . 但是,我有一个架构 . 这里是:

{
  "mappings": {
    "payment":{
      "properties":{
        "timestamp":{"type":"date"},
        "base_amount":{"type":"integer"},
        "derived_id":{"type":"keyword", "fielddata": true},
        "attempts":{"type":"integer"},
        "status":{"type":"text","fielddata":true},
        "error_code":{"type":"text","fielddata":true}
      }
    }
  }
}

这是我用来创建这个索引的代码

import json

import requests

schema = {
    "mappings": {
        "payment": {
            "properties": {
                "timestamp": {"type": "date"},
                "base_amount": {"type": "integer"},
                "derived_key": {"type": "keyword", "fielddata": True},
                "attempts": {"type": "integer"},
                "status": {"type": "text", "fielddata": True},
                "error_code": {"type": "text", "fielddata": True}
            }
        }
    }
}

index = 'http://localhost:9200/payment_index_2016_08_21'
r = requests.put(index, data=json.dumps(schema))

print r.content

我得到的错误是

{“error”:{“root_cause”:[{“type”:“mapper_parsing_exception”,“reason”:“[derived_key]的映射定义具有不受支持的参数:[fielddata:true]”}],“type”:“ mapper_parsing_exception“,”reason“:”无法解析映射[payment]:[derived_key]的映射定义具有不受支持的参数:[fielddata:true]“,”caused_by“:{”type“:”mapper_parsing_exception“,”reason“: “[derived_key]的映射定义具有不受支持的参数:[fielddata:true]”}},“status”:400}

我不明白为什么 fielddata = true 会导致问题,因为我认为这是允许的https://www.elastic.co/guide/en/elasticsearch/reference/current/fielddata.html . 有什么线索这背后的问题是什么?

1 回答

  • 1

    您无需在关键字字段上启用 fielddata . 您可以对关键字字段进行聚合 .

相关问题