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

在這裏插入圖片描述

測試結果

在這裏插入圖片描述

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