import sys
import os
import requests
import json
import conf

if __name__ == '__main__':
    for fname in os.listdir(sys.argv[1]):
        if fname.endswith('.txt'):
            query_id = fname.split('.')[0]
            query_url = '{0}/.percolator/{1}'.format(conf.ES_URL, query_id)
            with open(os.path.join(sys.argv[1], fname)) as f:
                query_obj = { 'query': { 'query_string': {
                    'default_field': conf.DEFAULT_FIELD,
                    'query': f.read() }}}
                response = requests.put(query_url, data=json.dumps(query_obj))
                assert response.status_code == 201
                print query_url

@@ -82,16 +82,44 @@
 ain__':%0A
+    bulk = %5B%5D%0A    count = 0%0A
     for 
@@ -152,16 +152,16 @@
 gv%5B1%5D):%0A
-
         
@@ -246,48 +246,99 @@
     
-query_url = '%7B0%7D/.percolator/%7B1%7D'.format
+bulk.append('%7B%22index%22:%7B%22_index%22:%22%25s%22,%22_type%22:%22.percolator%22,%22_id%22:%22%25s%22%7D%7D'%0A                %25 
 (con
@@ -346,11 +346,10 @@
 .ES_
-URL
+DB
 , qu
@@ -355,16 +355,17 @@
 uery_id)
+)
 %0A       
@@ -597,150 +597,493 @@
     
-response = requests.put(query_url, data=json.dumps(query_obj))%0A                assert response.status_code == 201%0A                print query_url
+bulk.append(json.dumps(query_obj))%0A                if len(bulk) == 100:%0A                    response = requests.put(conf.ES_URL + '_bulk',%0A                        data='%5Cn'.join(bulk) + '%5Cn')%0A                    assert response.status_code == 200%0A                    count += len(bulk)%0A                    print count%0A                    bulk = %5B%5D%0A%0A    if bulk:%0A        response = requests.put(conf.ES_URL + '_bulk', data='%5Cn'.join(bulk) + '%5Cn')%0A        assert response.status_code == 200
 %0A

use bulk API