Document Question
Closed this issue · 1 comments
I have run into confusion with the bulk es documentation on your readme.
var commands = []
commands.push({ "index" : { "_index" :'my_index_name', "_type" : "my_type_name"} })
commands.push({field1:'value',field2:'value'})
elasticSearchClient.bulk(commands, {})
.on('data', function(data) {})
.on('done', function(done){})
.on('error', function(error){})
.exec();
I assume, and I am sure other have as well that sending a large batch would use the following:
commands.push({ "index" : { "_index" :'my_index_name', "_type" : "my_type_name"} })
commands.push({field1:'value1',field2:'value'})
commands.push({field1:'value2',field2:'value'})
commands.push({field1:'value3',field2:'value'})
commands.push({field1:'value4',field2:'value'})
Through trial an error we found that we needed to include a 'index' statement before each document to bulk index.
commands.push({ "index" : { "_index" :'my_index_name', "_type" : "my_type_name"} })
commands.push({field1:'value1',field2:'value'})
commands.push({ "index" : { "_index" :'my_index_name', "_type" : "my_type_name"} })
commands.push({field1:'value2',field2:'value'})
commands.push({ "index" : { "_index" :'my_index_name', "_type" : "my_type_name"} })
commands.push({field1:'value3',field2:'value'})
commands.push({ "index" : { "_index" :'my_index_name', "_type" : "my_type_name"} })
commands.push({field1:'value4',field2:'value'})
Are we using the bulk correctly? Is this expected? Your repo, just need a few examples of implementations!
Thanks
Yes, the later example is correct. I discovered this the hard way too, but thats just the ES API.