本文介绍了插入批量数据不工作 - 弹性搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以基本上就是尝试新事物。这次用弹性搜索。我已经安装弹性和kibana,并感觉插件当然。
i尝试所有基本命令,如创建索引,映射,添加文档等。
一切顺利,直到我尝试批量插入。
code> 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杂志,价格:90.000,描述:swa magazine description,
status:active,quantity:3,categories :magazine}],
tags:[business,magazine,sales,news]}
我甚至不知道我的代码有什么问题。
i总是收到以下错误:
请帮助我解决这个问题。
非常感谢提前。
解决方案
每个文档必须在一行(即不能包含任何换行符) 。发送您的批量查询,如下所示:
POST / ecommerce / product / _bulk
{index:{_ id :1002}}
{名称:SWA杂志,价格:90.000,描述:swa杂志描述,状态 :3,category:[{name:magazine}],tags:[business,magazine,sales,news]}
{index {_id:1003}}
{name:SWA magazine,price:90.000,description:swa magazine description,status 数量:3,类别:[{name:magazine}],tags:[business,magazine,sales,news]}
粘贴在Sense中时,您应该只有第1到5行,而不是1到9。
so basically im trying new things. this time with elastic search.i already install elastic and kibana, and sense plugin of course.i try all basic command like create index, mapping, adding document etc.everything goes well until i try bulk insertion.
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"]}
i dont even know what is wrong with my code.i always got this error :
pls help me to fix this out.many thanks in advance.
解决方案
Each document must be on a single line (i.e. MUST NOT contain any newlines). Send your bulk query like this:
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"]}
When pasted in Sense, you should only have lines 1 through 5, not 1 through 9.
这篇关于插入批量数据不工作 - 弹性搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!