错误原文这样的
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [PlayerId] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "paymentdb",
"node": "ZicnPW_IRsCdYH_gUL3r9Q",
"reason": {
"type": "illegal_argument_exception",
"reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [PlayerId] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."
}
}
]
},
"status": 400
}
我的查询语句这样的:{"aggregations":{"totalPlayer":{"cardinality":{"field":"PlayerId"}}},"size":0}
4 个回复
shellmeng
赞同来自: hjqtlq 、laoyang360
如果你的索引中,该字段不是数值型(integer、double、long)或者keyword,而是text类型的,在使用该字段进行查询、排序、聚合时候,就会出现Fielddata is disabled on text fields by default.
解决办法:
1.把改字段的索引类型改成keyword或者数值型
或者
2:索引字段类型还是text,但是加mapping中fielddata=true。这种不推荐,因为这样加载时候,占用的内存
kennywu76 - Wood
赞同来自: hjqtlq
hjqtlq
赞同来自:
Erin
赞同来自: