I have multiple indices like mailbox-xx- xxxx .The xx-xxxx values are assigned dynamically. Each index contains various fields with date as a common field. The problem that date field has been read as long type by default , but I need to keep it as date type.
I tried to use _index_template API and specify only the date field in mappings, but I saw that data is not written to those indices since the mapping mismaches between the index template and actual query.
I'am on the version 7.16.
I want to create mapping for one common filed across multiple indices.
I deleted all the indices and created the mapping.
I started loading the data. I use _search api to see if the date field is mapped accordingly, but the indices are empty. If I remove the _index_template the loading works fine.
I understand what you are trying to do, but you didn't explained how you are loading the data.
If after the template was applied you got no data in the index, this could mean some kind of mapping issue, and you will get an error while trying to index the data in elasticsearch.
What are you using to index the data in elasticsearch?
I see, thank you for your reply.
I am not sure what client is used to load the data. It uses AWS Lambda python. The system is managed by another person so unfortunately I do not have much details.
THe loading json looks like that:
No, the only way to force a data type to a field is using a index template.
Your index template is correct and it is expected to work, but if you are not getting any data you need to check in the source of the data, the response that the AWS Lambda is getting to see if there is any error.
You may also check in your Elasticsearch logs to see if there is any hint.
I suspect that this may be causing some issues:
"_type": "P2"
Types are deprecates in Elasticsearch 7.X and should not be used any more, but I do not know if this would cause an issue in your case.
Yes, you are right!
I reviewed the reindexed indices, and saw that, when reindexed the original _type is replaced by _doc.
I need customized _type for kibana visualization lib filters.
At the same time some visualizations require date field in date format not long for average aggregation on date filed otherwise I am getting an error:
Can't get text on a VALUE_NULL at 1
Is there anyway, you think I can address this issue. The system in production and, I would eally like to avoid lots of changes?
So, you reindexed your indices after applying the template? You didn't shared this information before. The mapping is correct in the reindexed indices? If so, this means that the template is working.
You should create a custom field for it or use the tags field, types are deprecated in version 7.X and removed in version 8.X you need to move away from it if you want to have less issues when upgrading.
You may try to reindex it again, but this time specify the type destination index.
Thank you so much for your help.
Now I see it is version compatibility issue.
I tried multiple options, one was to manually reindex the available indices. The problem with this approach: I do not know the index pattern that may appear. Yes , the mapping is correct, but the new data is not written because of the _type field ( I have not yet tried your suggestions setting the _type while reindexing)
I have probably the last question, at least at this stage. I reviewed the indices that have been restored from the snapshot. They have versions between 7.0 - 7.13.
If I decide to downgrade to 6.8, will they work ? or at least back to 7.0?
The system is quite complex, was done by other person, I would like to skip rewriting all the queries, like replacing _type, setting field.keyword /s
Elasticsearch does not support downgrade, you would need to install an entirely new cluster in a version that has reached EOL and will not receive more updates, you also cannot restore a snapshot in a cluster with a lower version than the cluster that created the snapshot.
I think that in your case, you may be able to temporarily solve your problem using a runtime field, but be aware that this has an impact in performance.
A runtime field is a field mapping applied while reading, which means, while making queries, you may have your date field mapped as long in your index, but change it to a runtime field of the type date.
You will basically need to make the following request to your indices:
Hi,
I really appreciate your help, thanks a lot.
I think I will try to remove the _type field.
The one possible issue I may face is duplicating document _id's. I understood specifying different _type values allows having multiple documents with the same _id.
I consider the option of setting different indices with patterns like : initialIndex_initialType_month and setting a custom tag so I can use filters on index pattern like initialIndex* .
Anyway, thank you so much for your help, I helped a lot, without that I would definitely be blocked without seeing light at the end of the tonnel.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.