我有一种情况,我需要导入一堆不同的数据,这些数据最终可能会产生冲突的数据类型。我决定将所有内容都转换为字符串,然后在需要数据时再转换回来。我不知道如何使用 javascript 客户端通过 Elasticsearches (ES) 动态映射来做到这一点。
ES 在他们的文档中说什么:
{
"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"
}
}}
]
}}}
在他们的文档中它说“匹配名称以_es结尾的字符串字段”。
“匹配所有其他字符串字段”:https ://www.elastic.co/guide/en/elasticsearch/guide/current/custom-dynamic-mapping.html
这是我尝试过的,但没有将所有内容都转换为字符串(也尝试过在通配符周围不加引号):
event.mappings = {
"mytype": {
"match": "*",
"mapping": {
"type": "string"
}
}
}
我也试过了"match_mapping_type" : "*"
。
我已经尝试过:esClient.indices.putMapping({index:"myindex", type:"mytype", body:mybody})
在响应中和 .create 函数之外。有小费吗?