获取错误默认情况下,CURL中的文本字段禁用Fielddata

时间:2017-10-22 05:47:47

标签: java curl elasticsearch elasticsearch-plugin spring-data-elasticsearch

我试过这个命令:

curl -XPOST 'localhost:9200/bank/_search?pretty' -d ' { "size": 0, "aggs": { "group_by_state": { "terms": { "field": "state" } } } }'

当我执行它时,我总是在elasticSearch中收到此错误:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "Fielddata is disabled on text fields by default. Set   fielddata=true on [state] 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" : "bank",
        "node" : "B8uNFSm7TzO9KS3N72EFPg",
        "reason" : {
          "type" : "illegal_argument_exception",
          "reason" : "Fielddata is disabled on text fields by default. Set fielddata=true on [state] 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."
    `enter code here`    }
      }
    ]
  },
  "status" : 400
}enter code here

我该如何解决?

1 个答案:

答案 0 :(得分:2)

更改映射并重新编制索引

使用关键字类型 或者带有fielddata的文本:true