I have to store documents with a single field contains a single Json object. this object has a variable depth and variable schema. I config a mapping like this:
"mappings": {
"properties": {
"@timestamp": {
"type": "date"
},
"message": {
"type": "object"
}
}
}
It works fine and ElasticSearch creates and updates mapping with documents that received. The problem is that after some updates in mapping, it rejects new documents and do not update mapping anymore. At this time I change the indices and mapping update occurred for that indies. I'm looking forward to know the right solution.
for example the first document is:
{
personalInfo:{
fistName: "tom"
}
moviesStatistics: {
count: 100
}
}
the second document that will update ElasticSearch mapping is:
{
personalInfo:{
fistName: "tom",
lastName: "hanks"
},
moviesStatistics: {
count: 100
},
education: {
title: "a title..."
}
}
ElasticSearch creates mapping with doc1 and updates it with doc2, doc3, ... until a number of documents received. After that it starts to reject every document that is not matched to the last mapping fields.
CodePudding user response:
After all I found the solution in the home page of ElasticSearch https://www.elastic.co/guide/en/elasticsearch/reference/7.13//dynamic-field-mapping.html We can use Dynamic mapping and simply use this mapping:
"mappings": {
"dynamic": "true"
}