Node.js 弹性JS节点JS无法更新索引
我在尝试使用express更新elasticJS上的索引时出现了一个奇怪的错误:Node.js 弹性JS节点JS无法更新索引,node.js,express,elasticjs,Node.js,Express,Elasticjs,我在尝试使用express更新elasticJS上的索引时出现了一个奇怪的错误: router.put('/update/:id', async (req, res) => { try { console.log('Entered updateuser', req.params.id); const salt = await bcrypt.genSalt(10); let password = await bcrypt.hash(req.body.passwor
router.put('/update/:id', async (req, res) => {
try {
console.log('Entered updateuser', req.params.id);
const salt = await bcrypt.genSalt(10);
let password = await bcrypt.hash(req.body.password, salt);
const data = {
email: req.body.email,
firstName: req.body.firstName,
lastName: req.body.lastName,
phone: req.body.phone,
password
};
await client.update({
index: 'users',
type: 'mytype',
id: req.params.id,
body: data
});
res.json({ msg: 'Updated Successfully' });
} catch (err) {
// res.status(500).send(err.message);
console.log(err);
}
});
我检查了所有参数,但发现一个错误:
use the endpoint /{index}/_update/{id} instead."' ],
[0] meta:
[0] { context: null,
[0] request: [Object],
[0] name: 'elasticsearch-js',
[0] connection: [Object],
[0] attempts: 0,
[0] aborted: false } } }
[0] Entered updateuser GIt7NW0BKLEzmnN0prT2
[0] { ResponseError: x_content_parse_exception
[0] request: [Object],
[0] name: 'elasticsearch-js',
[0] connection: [Object],
[0] attempts: 0,
[0] aborted: false } } }
有人知道问题出在哪里吗?如果您想使用
更新
api并更新文档的一部分,您必须将更改打包到文档中
await client.update({
index: 'users',
type: 'mytype',
id: req.params.id,
body: {
doc: data // <===
}
});
wait client.update({
索引:“用户”,
类型:“mytype”,
id:req.params.id,
正文:{
doc:data/如果您想使用更新api并更新文档的一部分,您必须将更改打包到doc
中
await client.update({
index: 'users',
type: 'mytype',
id: req.params.id,
body: {
doc: data // <===
}
});
wait client.update({
索引:“用户”,
类型:“mytype”,
id:req.params.id,
正文:{
doc:data//发送给elastic的请求正文错误。这意味着数据中的某个变量缺失或未发送correctly@NikosM.嗯,我检查了所有字段,没有遗漏任何内容。也许他们错了format@NikosM.它们都是字符串,我不认为是,也许我遗漏了一些参数?这是errorResponseError:x\u content\u parse\u exception
,快速查找产生:,发送到elastic的请求正文错误。这意味着数据中的某个变量缺失或未发送correctly@NikosM.嗯,我检查了所有字段,没有遗漏任何内容。也许他们错了format@NikosM.它们都是绳子s、 我不认为是这样,也许我遗漏了一些参数?这是错误ResponseError:x\u content\u parse\u exception
,快速查找会产生:,