Error: Fielddata is disabled on text fields

I am following the operation of the video "getting started with Elasticsearch",

I post several indices into the Elasticsearch by using POST /inspections/_doc/_bulk, the documents of the indices include "inspection_score": 96 . But when I use the following command to sort the documents according to the value of "inspection_score", just as the video does.
GET /inspections/_doc/_search
"range": {
"inspection_score": {
"gte": 80
"inspection_score": "desc"



I got the error: "Fielddata is disabled on text fields by default. Set fielddata=true on [inspection_score] in order to load fielddata in memory by uninverting the inverted index.

Why? The video shows everything is fine. By the way, is "inspection_score" of type text? I think it maybe number since in the POST command, I specify a number to the value of "inspection_score".

hi @li_jessen2016

fielddata is indeed disabled by default on text-fields. For more info see here

I would first check the mapping of your index, and verify what field-type the inspection_score field has.

I delete the indices. And post in bulk again. It works. It maybe previously I used "96" text as the value of inspection_score and it stayed there until I deleted them all.

PUT /index_name
your mapping here
"mappings": {}

First use this method to create a mapping for your index. Then push the data.

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