Skip to content Skip to sidebar Skip to footer

Indexing On Amazon Elasticsearch Service - Bulk Insert

I have an Amazon Elasticsearch instance which is active, and I'm able to connect and execute statements through 'Sense' from Chrome. But when I try to do bulk inserts, it shows 'ti

Solution 1:

You are doing it wrong I think.

A bulk request is a 2 lines combination in the "body" field of the bulk method.

{"index":{"_index":"test","_type":"type1","_id":"1"}}{"field1":"value1"}

Here is what you should have in your body field.

The first line contains the type of request, the index where you bulk and a lot of other params that you can set or not (check documentation). Add a \r\n at the end of the first line.

The second line must contains what you're trying to insert.

If you check what you're putting into dict_list, you forgot the index method call.

Wrong structure :

dict_list.append({'_type':'doc', '_index':'es_index', '_id':rows[i][0], 'column2':rows[i][1], 'column3':rows[i][2]})

Right structure :

{ "index" : {'_type':'doc', '_index':'es_index', '_id':rows[i][0]} }

And then add your document on a second line.

Post a Comment for "Indexing On Amazon Elasticsearch Service - Bulk Insert"