Elasticsearch Batch Manipulation--bulk API

Source: Internet
Author: User

The bulk processing functionality provided by Elasticsearch is implemented by using the _bulk API. This feature is important because it provides a very efficient mechanism to complete multiple operations as quickly as possible, while using as few network round trips as possible.

1, batch index, that is, batch add documents

Two documents (ID 1-john doe and ID 2-jane Doe) were indexed in a bulk operation at a reduced time:

Curl-xpost'Localhost:9200/customer/external/_bulk?pretty'-D'{"Index":{"_id":"1"}}         {"name":"John Doe" }         {"Index":{"_id":"2"}}         {"name":"Jane Doe" }         '

2, the following example in a bulk operation, first update the first document (ID 1), and then delete the second document (ID 2):

Curl-xpost'Localhost:9200/customer/external/_bulk?pretty'-D'{"Update":{"_id":"1"}}         {"Doc": {"name":"John Doe becomes Jane Doe" } }         {"Delete":{"_id":"2"}}         '

Note the delete action above, because the delete action only needs to be deleted document ID, so there is no corresponding source document.

The bulk API performs these actions sequentially. If one of the actions fails for some reason, it will continue to handle the actions behind it. When the bulk API returns, it will provide the status of each action (in the same order), so you can see whether an action is successful or not.

Elasticsearch Batch Manipulation--bulk API

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.