添加到 ES 时 JSON 数组出现 mapper_parsing_exception 错误
mapper_parsing_exception error for JSON array while adding into ES
我正在尝试使用以下代码将对象数组创建到 ES 中。除此参数外,其余参数均正确插入。我认为这是因为数据类型问题
var body = {
"expertise": [{
"productName": "solution architecture"
},
{
"productName": "product architecture"
}
]
}
client.index({
index: index,
type: type,
body: body
}, function(error, resp, status) {
if (error) {
console.log(error);
callback(error);
}
console.log('success');
callback(null, event);
});
ES 支持 JSON 数组数据类型 https://www.elastic.co/guide/en/elasticsearch/reference/current/nested.html 那么为什么我会收到这样的错误。
我收到错误
"errorMessage": "[mapper_parsing_exception] failed to parse [expertise]",
"errorType": "Error",
"stackTrace": [
"respond (/var/task/node_modules/elasticsearch/src/lib/transport.js:308:15)",
"checkRespForFailure (/var/task/node_modules/elasticsearch/src/lib/transport.js:267:7)",
"HttpConnector.<anonymous> (/var/task/node_modules/elasticsearch/src/lib/connectors/http.js:165:7)",
通过换key解决。
"expertises": [ // instead of expertise i used expertises
{
"productName": "solution architecture"
},
{
"productName": "product architecture"
}
]
我正在尝试使用以下代码将对象数组创建到 ES 中。除此参数外,其余参数均正确插入。我认为这是因为数据类型问题
var body = {
"expertise": [{
"productName": "solution architecture"
},
{
"productName": "product architecture"
}
]
}
client.index({
index: index,
type: type,
body: body
}, function(error, resp, status) {
if (error) {
console.log(error);
callback(error);
}
console.log('success');
callback(null, event);
});
ES 支持 JSON 数组数据类型 https://www.elastic.co/guide/en/elasticsearch/reference/current/nested.html 那么为什么我会收到这样的错误。
我收到错误
"errorMessage": "[mapper_parsing_exception] failed to parse [expertise]",
"errorType": "Error",
"stackTrace": [
"respond (/var/task/node_modules/elasticsearch/src/lib/transport.js:308:15)",
"checkRespForFailure (/var/task/node_modules/elasticsearch/src/lib/transport.js:267:7)",
"HttpConnector.<anonymous> (/var/task/node_modules/elasticsearch/src/lib/connectors/http.js:165:7)",
通过换key解决。
"expertises": [ // instead of expertise i used expertises
{
"productName": "solution architecture"
},
{
"productName": "product architecture"
}
]