Overview :
A mapping inside elasticsearch can be dynamic and static. Both mapping has there own pros and cons. For initial phase dynamic mapping is ok, because we won't have complete knowledge of data model and it's usability. But after some point of time we can decide which all fields need to be indexed.
Problem statement :
In sunbird we are using dynamic mapping ,for data indexed, Inside Elastic search default indexed limit is 1000, So if your index reached 1000 limit , then it won't allow any other key to be indexed.
Now in sunbird we reached the limit.
Solution 1:
Dynamic mapping can be turn off and will used static mapping . Static mapping can be of two type.
- flexible static mapping : In this case first time we can define all attribute and it's type, and elasticseaerch will do indexing for only those attribute ,which is already defined in mapping, and it will allow user to store other attribute as well without indexing.
- Strict mapping : In this case first time we can define all attribute and it's type, and elasticseaerch will do indexing for only those attribute ,which is already defined in mapping, and it will throw error if any new attribute is introduced.
// Flexible static mapping { "dynamic": false, "properties": { } }
// Strict static mapping { "dynamic": "strict", "properties": { } }
Solution 2:
We can increase limit of index form 1000 to 1500 as follow:
curl -X PUT http://localhost:9200/searchindex/settings -H 'cache-control: no-cache' -H 'content-type: application/json' -H 'postman-token: e2b31e11-6678-ae40-288b-32f51705f7f7' -d '{ "index.mapping.totalfields.limit": 1500 }'
Curl command to do mapping:
Method : Put
http://localhost:9200/searchindex/batch/_mapping
{
"dynamic": false,
"properties":
}
-- New Mapping files
-- Old Mapping files: