elasticsearch - 在添加到 ES 时 JSON 数组的 mapper_parsing_exception 错误
问题描述
我正在尝试使用以下代码将对象数组创建到 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)",
解决方案
这是通过更改密钥来解决的。
"expertises": [ // instead of expertise i used expertises
{
"productName": "solution architecture"
},
{
"productName": "product architecture"
}
]
推荐阅读
- c# - 如何从 ActiveX 组件中保存位图
- pentaho - 基于用户登录,需要在 pentaho CDE 仪表板中更改数据源连接
- c++ - 在 C++ 中创建不可变且高效的类的惯用方法
- ios - 在两个不同的类中对同一文件使用委托
- mysql - 我的查询在 MySQL 工作台和 phpmyadmin 中有效,但在 node.js 中无效
- amazon-web-services - AWS 上的无服务器任务调度
- css - 是否可以将 css 变量保存到 scss 变量中?
- php - 无法使用 mysqli_fetch_assoc($result) 从数据库中获取
- php - PHP处理数据并创建数组
- javascript - Angular:如何防止组件模板同时闪烁两个条件语句?