【发布时间】:2015-10-20 15:25:32
【问题描述】:
如果我把这样的文件:
$ curl -XPOST "http://localhost:9200/test/test/" -d '
{
"books": {
"id1": {
"name": "Hello World!"
},
"id2": {
"name": "Hitchhiker Guide To The Galaxy"
}
}
}'
然后它会创建一个这样的映射:
$ curl -XGET "http://localhost:9200/test/test/_mapping"
{
"test":{
"mappings":{
"test":{
"properties":{
"books":{
"properties":{
"id1":{
"properties":{
"name":{
"type":"string"
}
}
},
"id2":{
"properties":{
"name":{
"type":"string"
}
}
}
}
}
}
}
}
}
}
“books”对象中的属性/键是动态的,映射会无限增长。如何让 ES 不查看“books”的键并使其了解“books”中的每个值都属于同一类型?例如。映射不应包含每个图书 ID 的新条目。
【问题讨论】:
-
你为什么要这样做?为什么键列表无穷无尽?你不给这个属性一个意义吗?
-
每个文档,地图中有大约 1-5 个条目(在此特定示例中为“书籍”)。但由于每个文档的 id 不同 - 映射继续增长。
-
你为什么不做一个属性id并将id号存储在那里?我认为您正试图以错误的方式解决此问题。只是我的 2c。
标签: elasticsearch elasticsearch-mapping