title: How to use Bulk API to store the keywords in ES by using Python
body: <p>I have to store some message in ElasticSearch integrate with my python program. 
  Now what I try to store the message is:</p>
  
  <pre><code>d={"message":"this is message"}
      for index_nr in range(1,5):
          ElasticSearchAPI.addToIndex(index_nr, d)
          print d
  </code></pre>
  
  <p>That means if I have 10 messages then I have to repeat my code 10 times. 
  So what I want to do is try to make a script file or batch file.
  I've checked the <a href="http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-bulk.html" rel="noreferrer">ElasticSearch Guide</a>, BULK API is possible to use. 
  The format should be something like below:</p>
  
  <pre><code>{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" } }
  { "field1" : "value1" }
  { "delete" : { "_index" : "test", "_type" : "type1", "_id" : "2" } }
  { "create" : { "_index" : "test", "_type" : "type1", "_id" : "3" } }
  { "field1" : "value3" }
  { "update" : {"_id" : "1", "_type" : "type1", "_index" : "index1"} }
  { "doc" : {"field2" : "value2"} }
  </code></pre>
  
  <p>what I did is: </p>
  
  <pre><code>{"index":{"_index":"test1","_type":"message","_id":"1"}}
  {"message":"it is red"}
  {"index":{"_index":"test2","_type":"message","_id":"2"}}
  {"message":"it is green"}
  </code></pre>
  
  <p>I also use curl tool to store the doc. </p>
  
  <pre><code>$ curl -s -XPOST localhost:9200/_bulk --data-binary @message.json
  </code></pre>
  
  <p>Now I want to use <strong>my Python code</strong> to store the file to the Elastic Search.</p>