Could not Perform aggregations :illegal_argument_exception

I created an index megacorp. PUT 3 documents in it through kibana console.

eg..
PUT /megacorp/employee/2
{
"first_name" : "Jane",
"last_name" : "Smith",
"age" : 32,
"about" : "I like to collect rock albums",
"interests": [ "music" ]
}

when I try to perform aggregations by passing below request through kibana console..

GET megacorp/employee/_search
{
  "aggs": {
    "all_interests": {
      "terms": {
        "field": "interests"
      }
    }
  }
}

I am getting this error response..

{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [interests] 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": "megacorp",
        "node": "PTK-1g-dR-CV0KXVD5eMSQ",
        "reason": {
          "type": "illegal_argument_exception",
          "reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [interests] 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."
        }
      }
    ]
  },
  "status": 400
}

Could anyone help me with this....I followed elastic-search definitive guide(2.x) to do this...I am using elastic search 6.2.4 on Windows...

run the agg on

interests.keyword

Could you please post me editing my request...Couldn't understand exactly what you want me to change.

"filed": "interests.keyword"

Got it!..Thank you very much

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.