I have a situation where I'll need to import a bunch of different data that may end up having conflicting data types. I have decided to convert everything to a string and then convert back later if the data is needed. I can't figure out how to do this with Elasticsearches (ES) dynamic mapping using the javascript client.
What ES says in their docs:
{
"mappings": {
"my_type": {
"dynamic_templates": [
{ "es": {
"match": "*_es",
"match_mapping_type": "string",
"mapping": {
"type": "string",
"analyzer": "spanish"
}
}},
{ "en": {
"match": "*",
"match_mapping_type": "string",
"mapping": {
"type": "string",
"analyzer": "english"
}
}}
]
}}}
in their docs it says " Match string fields whose name ends in _es".
"Match all other string fields": https://www.elastic.co/guide/en/elasticsearch/guide/current/custom-dynamic-mapping.html
This is what I've tried, but doesn't convert all to string (also tried without quotes around wildcard):
event.mappings = {
"mytype": {
"match": "*",
"mapping": {
"type": "string"
}
}
}
I've also tried "match_mapping_type" : "*"
.
I've tried: esClient.indices.putMapping({index:"myindex", type:"mytype", body:mybody})
in the response and outside of the .create function.
Any tips?