Elasticsearch supports batch addition or deletion of index documents. In Java APIs, bulkrequestbuilder is constructed, batch index/delete requests are added to bulkrequestbuilder, and bulkrequestbuilder is executed. The following is an example:
Import static Org. elasticsearch. common. xcontent. xcontentfactory. *; bulkrequestbuilder bulkrequest = client. preparebulk (); bulkrequest. add (client. prepareindex ("Twitter", "tweet", "1 "). setsource (jsonbuilder (). startobject (). field ("user", "kimchy "). field ("postdate", new date ()). field ("message", "trying out elastic search "). endobject (); bulkrequest. add (client. prepareindex ("Twitter", "tweet", "2 "). setsource (jsonbuilder (). startobject (). field ("user", "kimchy "). field ("postdate", new date ()). field ("message", "another post "). endobject (); bulkresponse = bulkrequest.exe cute (). actionget (); If (bulkresponse. hasfailures () {// handle error}
Add index Operation Reference: http://blog.csdn.net/laigood12345/article/details/7460544
Index deletion operation reference: http://blog.csdn.net/laigood12345/article/details/7460602
References: http://www.elasticsearch.org/guide/reference/java-api/bulk.html
Address: http://blog.csdn.net/laigood12345/article/details/7606079