ElasticSearch Error - Fielddata is disabled on text fields by default

edx
edx
58 Points
19 Posts

I have created new index from existing one by using following Query DSL:

POST _reindex
{
  "source": {
    "index": "myindex"
  },
  "dest": {
    "index": "new_myindex"
  }
}

Now, tried to search on new index but now I'm getting following error:

{
   "error": {
      "root_cause": [
         {
            "type": "illegal_argument_exception",
            "reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [fullName] 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": "new_myindex",
            "node": "6eVW0YQrQf2rO5r0o5RJvA",
            "reason": {
               "type": "illegal_argument_exception",
               "reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [fullName] 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
}

How to enable field data in elastic-search?

Views: 7620
Total Answered: 2
Total Marked As Answer: 2
Posted On: 29-Mar-2019 05:47

Share:   fb twitter linkedin
Answers
Rashmi
Rashmi
Member
112 Points
26 Posts
         

Use following query dsl command:

PUT my_index/my_type/_mapping
{
  "properties": {
    "my_field": {
      "type":     "text",
      "fielddata": true
    }
  }
}
Posted On: 30-Mar-2019 00:59
Brian
Brian
Participant
580 Points
75 Posts
         

According to ElasticSearch reference

https://www.elastic.co/guide/en/elasticsearch/reference/5.0/fielddata.html 

"Fielddata can consume a lot of heap space, especially when loading high cardinality text fields. Once fielddata has been loaded into the heap, it remains there for the lifetime of the segment. Also, loading fielddata is an expensive process which can cause users to experience latency hits. This is why fielddata is disabled by default."

If you try to sort, aggregate, or access values from a script on a text field then you will see this exception:

Fielddata is disabled on text fields by default

You need to set fielddata=true on field in order to load fielddata in memory by uninverting the inverted index. Doing this can use significant memory.

Posted On: 12-Apr-2019 09:23
 Log In to Chat