Skip to content
Advertisement

how to load 1000 lines of a csv into elasticsearch as 1000 different documents using elasticsearch API

so ive been trying to load 1000 lines of a csv into elasticsearhc as 1000 different documents, the csv has 8 headers: telease year, title, origin/ethnicity, director, cast, wiki page, plot. my current code for loading the dataset loads it using the bulk command from helpers

JavaScript

this i think loads 1000 lines into one document.

Advertisement

Answer

You are on the right path, the code below will split the csv into 1000 different items but splitting out the headers and turning each line item into a map/dictionary item with appropriate headers. This is then appended to a list so you upload a list of dictionary items.

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement