问题
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