ES- Set fielddata=true on [actorList.name] in order to load fielddata in memory by......

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
    }
  }
}

在这里插入图片描述

测试结果

在这里插入图片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章