索引映射时不支持 Elasticsearch 字段数据
Elasticsearch fielddata unsupported while index mapping
我正在尝试通过 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":"Mapping
definition for [derived_key] has unsupported parameters: [fielddata :
true]"}],"type":"mapper_parsing_exception","reason":"Failed to parse
mapping [payment]: Mapping definition for [derived_key] has
unsupported parameters: [fielddata :
true]","caused_by":{"type":"mapper_parsing_exception","reason":"Mapping
definition for [derived_key] has unsupported parameters: [fielddata :
true]"}},"status":400}
我不明白为什么 fielddata = true
会导致问题,因为我看到这里允许这样做 https://www.elastic.co/guide/en/elasticsearch/reference/current/fielddata.html。知道这背后的问题是什么吗?
您不需要在关键字字段上启用 fielddata
。您可以对关键字字段进行聚合。
我正在尝试通过 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":"Mapping definition for [derived_key] has unsupported parameters: [fielddata : true]"}],"type":"mapper_parsing_exception","reason":"Failed to parse mapping [payment]: Mapping definition for [derived_key] has unsupported parameters: [fielddata : true]","caused_by":{"type":"mapper_parsing_exception","reason":"Mapping definition for [derived_key] has unsupported parameters: [fielddata : true]"}},"status":400}
我不明白为什么 fielddata = true
会导致问题,因为我看到这里允许这样做 https://www.elastic.co/guide/en/elasticsearch/reference/current/fielddata.html。知道这背后的问题是什么吗?
您不需要在关键字字段上启用 fielddata
。您可以对关键字字段进行聚合。