我有一个样本json,想要将其索引到Elasticsearch中。 索引的样本Json:
put test/names/1
{
"1" : {
"name":"abc"
},
"2" : {
"name":"def"
},
"3" : {
"name":"xyz"
}
}
现在,elasticsearch生成的默认映射如下:
其中, 索引名称:test, 类型名称:names, ID:1。
{
"test": {
"mappings": {
"names": {
"properties": {
"1": {
"properties": {
"name": {
"type": "string"
}
}
},
"2": {
"properties": {
"name": {
"type": "string"
}
}
},
"3": {
"properties": {
"name": {
"type": "string"
}
}
},
"metadataFieldDefinition": {
"properties": {
"name": {
"type": "string"
}
}
}
}
}
}
}
}
如果地图大小从3(当前)增加到千或百万级别,那么ElasticSearch将为每个地图创建一个映射,这可能会导致性能问题,因为映射集合将非常庞大。
我尝试通过设置以下内容来创建映射:
"dynamic":false,
"type":object
但是它被ES覆盖了,因为它与索引数据不匹配。
请告诉我如何定义一个映射,以便ES不会创建像上面那样的映射。