4

I tried this command:

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

When I'm executing it, then I always getting this error in 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

How can I solve it?

Christian Gollhardt
  • 16,510
  • 17
  • 74
  • 111
Parminder Singh
  • 131
  • 3
  • 10
  • If you search in SO you'll find the answer: https://stackoverflow.com/questions/41868377/elasticsearch-fielddata-should-i-use-it – Val Oct 22 '17 at 05:53

1 Answers1

4

Change your mapping and reindex

Use keyword type or text type with fielddata: true

dadoonet
  • 14,109
  • 3
  • 42
  • 49