Elasticsearch [index.highlight.max_analyzed_offset] limit [1000000] problem


When some of the fields have length more then 1000000 you will see the following error from Kibana

The length [1064174] of field [properties.files.content] in doc[132067]/index[posts] exceeds the [index.highlight.max_analyzed_offset] limit [1000000]. To avoid this error, set the query parameter [max_analyzed_offset] to a value less than index setting [1000000] and this will tolerate long field values by truncating them.

to avoid this, you can change the highlight.max_analyzed_offset value by doing the following call

curl -XPUT "localhost:9200/posts/_settings" -H 'Content-Type: application/json' -d' {
    "index" : {
        "highlight.max_analyzed_offset" : 20000000
    }
}