如何在 Elastic-search 中创建子对象 7.x
How to create a sub object in Elastic-search 7.x
之前我使用的是 1.x 版本,并使用以下语法创建子对象映射。
"foo": {
"type": "integer",
"doc_values": true
},
"foo.bar": {
"type": "integer",
"doc_values": true
},
"foo.bar.baz": {
"type": "integer",
"doc_values": true
},
但是现在,当我在 ES 7.x 中使用相同的映射语法时,出现以下错误:-
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Can't merge a non object mapping [foo] with an object mapping [foo]"
}
],
"type": "illegal_argument_exception",
"reason": "Can't merge a non object mapping [foo] with an object mapping [foo]"
},
"status": 400
}
我是这么过来的 post Can’t merge a non object mapping with an object mapping error in machine learning(beta) module 但是,注意我没有更新映射,而是创建了一个新的映射仍然出现这个错误,请指教怎么办?
一个对象类型的例子。有关详细信息,请参阅 here
"mappings": {
"properties": {
"user": {
"properties": {
"age": { "type": "integer" },
"name": {
"properties": {
"first": { "type": "text" },
"last": { "type": "text" }
}
}
}
}
}
下面的名称可以定义为对象,可以使用 name.firstname 等添加更多属性。在您的映射中 foo 是整数类型,然后您添加 foo.bar 所以它抛出错误. foo 必须是对象类型。
"properties" : {
"name" : {
"type" : "object"
},
"name.firstname":{
"type" : "text"
},
"name.lastname":{
"type" : "text"
}
}
之前我使用的是 1.x 版本,并使用以下语法创建子对象映射。
"foo": {
"type": "integer",
"doc_values": true
},
"foo.bar": {
"type": "integer",
"doc_values": true
},
"foo.bar.baz": {
"type": "integer",
"doc_values": true
},
但是现在,当我在 ES 7.x 中使用相同的映射语法时,出现以下错误:-
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Can't merge a non object mapping [foo] with an object mapping [foo]"
}
],
"type": "illegal_argument_exception",
"reason": "Can't merge a non object mapping [foo] with an object mapping [foo]"
},
"status": 400
}
我是这么过来的 post Can’t merge a non object mapping with an object mapping error in machine learning(beta) module 但是,注意我没有更新映射,而是创建了一个新的映射仍然出现这个错误,请指教怎么办?
一个对象类型的例子。有关详细信息,请参阅 here
"mappings": {
"properties": {
"user": {
"properties": {
"age": { "type": "integer" },
"name": {
"properties": {
"first": { "type": "text" },
"last": { "type": "text" }
}
}
}
}
}
下面的名称可以定义为对象,可以使用 name.firstname 等添加更多属性。在您的映射中 foo 是整数类型,然后您添加 foo.bar 所以它抛出错误. foo 必须是对象类型。
"properties" : {
"name" : {
"type" : "object"
},
"name.firstname":{
"type" : "text"
},
"name.lastname":{
"type" : "text"
}
}