Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "Limit of total fields [1000] in index [] has been exceeded" means in Elasticsearch

I have Elasticsearch index created which has approx 350 fields (Including nested fields) , I have defined mapping only for few of them. While calling _update API I am getting below exception with 400 Bad request.

Limit of total fields [1000] in index [test_index] has been exceeded
I want to understand the exact reason for this exception since my number of fields and fields for which mapping is defined both are less than 1000.
Note: I have nested fields and dynamic mapping enabled.

Regards,
Sandeep

like image 699
SSG Avatar asked Mar 27 '19 08:03

SSG


3 Answers

You can fix the issue by increasing the value of index.mapping.total_fields.limit (default 1000)

index.mapping.total_fields.limit

The maximum number of fields in an index. Field and object mappings, as well as field aliases count towards this limit. The default value is 1000.

To increase total fields limit to 2000, try this

PUT test_index/_settings
{
  "index.mapping.total_fields.limit": 2000
}

The reason to limit the number of fields is :

Defining too many fields in an index is a condition that can lead to a mapping explosion, which can cause out of memory errors and difficult situations to recover from. This is quite common with dynamic mappings. Every time a document contains new fields, those will end up in the index’s mappings

Related Resources :
1. Get the number of fields on an index
2. Settings to prevent mappings explosion

like image 196
Ashraful Islam Avatar answered Oct 11 '22 17:10

Ashraful Islam


Another approach to handle this is to carefully design the mappings as the OP seems to be doing and to turn off dynamic mapping by setting dynamic = false (or even dynamic = strict)

Note that this approach can be applied to the entire mapping or to other properties/nested objects within, which enables quite a bit good degree of flexibility.

Reference to Dynamic mapping in the docs

like image 29
elachell Avatar answered Oct 11 '22 18:10

elachell


I landed here via google. This worked for me (from the shell):

curl -s -XPUT http://localhost:9200/test-index/_settings  -H 'Content-Type: application/json' -d '{"index.mapping.total_fields.limit": 2000}'
like image 29
Marco Avatar answered Oct 11 '22 17:10

Marco