ES- Set fielddata=true on [actorList.name] in order to load fielddata in memory by......
程序员文章站
2022-05-19 10:57:01
...
GET movie_index/_search
{
"aggs": {
"b": {
"terms": {
"field": "actorList.name",
"size": 10
}
, "aggs": {
"sum": {
"sum": {
"field": "doubanScore"
}
}
}
}
}
}
actorList.name为字符串!
查询结果
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [actorList.name] 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": "movie_index",
"node": "t4MN3grvQfGgAmxYlSCkpw",
"reason": {
"type": "illegal_argument_exception",
"reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [actorList.name] 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."
}
}
],
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [actorList.name] 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.",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [actorList.name] 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."
}
}
参考官方文档ES官方文档fielddata
解决方法
方法一
方法2(本质一样)
in my case
PUT movie_index/_mapping/movie
{
"properties": {
"actorList.name": {
"type": "text",
"fielddata": true
}
}
}