1

所以基本上我在尝试新事物。这次是弹性搜索。我已经安装了 elastic 和 kibana,当然还有 sense 插件。我尝试了所有基本命令,如创建索引、映射、添加文档等。一切顺利,直到我尝试批量插入。

POST /ecommerce/product/_bulk
{"index":{"_id":"1002"}}
{"name":"SWA magazine", "price":"90.000", "description":"swa magazine description",
"status":"active", "quantity":3, "categories":[{"name":"magazine"}], 
"tags":["business", "magazine", "sales", "news"]}
{"index":{"_id":"1003"}}
{"name":"SWA magazine", "price":"90.000", "description":"swa magazine description",
"status":"active", "quantity":3, "categories":[{"name":"magazine"}], 
"tags":["business", "magazine", "sales", "news"]}

我什至不知道我的代码有什么问题。我总是收到这个错误:在此处输入图像描述

请帮我解决这个问题。提前谢谢了。

4

1 回答 1

2

每个文档必须位于一行(即不得包含任何换行符)。像这样发送您的批量查询:

POST /ecommerce/product/_bulk
{"index":{"_id":"1002"}}
{"name":"SWA magazine", "price":"90.000", "description":"swa magazine description","status":"active", "quantity":3, "categories":[{"name":"magazine"}], "tags":["business", "magazine", "sales", "news"]}
{"index":{"_id":"1003"}}
{"name":"SWA magazine", "price":"90.000", "description":"swa magazine description", "status":"active", "quantity":3, "categories":[{"name":"magazine"}], "tags":["business", "magazine", "sales", "news"]}

在 Sense 中粘贴时,您应该只有第 1 到第 5 行,而不是第 1 到 9 行。

于 2016-06-28T07:17:48.103 回答