我正在尝试通过 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。任何线索这背后的问题是什么?