我需要有关嵌套json文档的弹性搜索映射的帮助。我在网上进行了很多搜索,但没有找到任何有用的信息。假设我有这种类型的数据。
{
"name" : "Zach",
"car" : [
{
"make" : "Saturn",
"model" : "SL"
},
{
"make" : "Subaru",
"model" : "Imprezza"
}
]
}
{
"name" : "Bob",
"car" : [
{
"make" : "Saturn",
"model" : "Imprezza"
}
]
}
汽车内可以有任意数量的数据对象。根据弹性搜索文档,我知道对于嵌套json,我必须将类型指定为嵌套。但是没有关于如何在该嵌套类型下指定变量的映射信息的信息。
像上面的示例一样,我可以这样编写映射。
{
"person":{
"properties":{
"name" : {
"type" : "string"
},
"car":{
"type" : "nested"
}
}
}
}
但是如何为car.make
&提供映射信息car.model
?
可以正常工作而不会出现任何将来的问题吗?
{
"person": {
"properties": {
"name" : {
"type" : "string"
},
"car": {
"type" : "nested"
"properties": {
"make": {....},
"model": {....}
}
}
}
}
}
您可以这样做:
PUT /my_index
{
"mappings": {
"blogpost": {
"properties": {
"comments": {
"type": "nested",
"properties": {
"name": { "type": "string" },
"comment": { "type": "string" },
"age": { "type": "short" },
"stars": { "type": "short" },
"date": { "type": "date" }
}
}
}
}
}
}
引用ES最终指南的这一部分。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句