PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, October 25, 2022

[FIXED] How to fix ElasticSearch ‘Fielddata is disabled on text fields by default’ for keyword field

 October 25, 2022     aws-elasticsearch, elasticsearch     No comments   

Issue

I'm getting the "Fielddata is disabled on text fields by default" on a keyword field. Below is the code.

{
 "aggs": {
   "agg_terms_user": {
     "terms": {
       "field": "user"
     }
   }
 }
}

The mapping for the user field is as below

user: { type: "keyword" }

Since the user field has type set as keyword I shouldn't get the error. However, the error is still thrown.

[illegal_argument_exception] Fielddata is disabled on text fields by default. Set fielddata=true on [user] 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.

I don't know what to try now.


Solution

I found the reason behind the unexpected error. The ES wasn't getting re-indexed properly. Once I deleted the indexed first and then recreated it then it started working like a charm.



Answered By - Nikhil
Answer Checked By - Mary Flores (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing