Insertion Bulk data not work - elastic search

瘦欲@ 提交于 2019-12-14 02:46:58

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/38069413/insertion-bulk-data-not-work-elastic-search

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!