本文主要是介绍Elasticsearch java API (11)Bulk API,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Bulk API编辑 Bulk API允许一个指数和删除几个文件在一个单一的请求。 这是一个示例用法: import static org.elasticsearch.common.xcontent.XContentFactory.*;BulkRequestBuilder bulkRequest = client.prepareBulk();// either use client#prepare, or use Requests# to directly build index/delete requests
bulkRequest.add(client.prepareIndex("twitter", "tweet", "1").setSource(jsonBuilder().startObject().field("user", "kimchy").field("postDate", new Date()).field("message", "trying out Elasticsearch").endObject()));bulkRequest.add(client.prepareIndex("twitter", "tweet", "2").setSource(jsonBuilder().startObject().field("user", "kimchy").field("postDate", new Date()).field("message", "another post").endObject()));BulkResponse bulkResponse = bulkRequest.get();
if (bulkResponse.hasFailures()) {// process failures by iterating through each bulk response item
}
import static org.elasticsearch.common.xcontent.XContentFactory.*;BulkRequestBuilder bulkRequest = client.prepareBulk();// either use client#prepare, or use Requests# to directly build index/delete requests
bulkRequest.add(client.prepareIndex("twitter", "tweet", "1").setSource(jsonBuilder().startObject().field("user", "kimchy").field("postDate", new Date()).field("message", "trying out Elasticsearch").endObject()));bulkRequest.add(client.prepareIndex("twitter", "tweet", "2").setSource(jsonBuilder().startObject().field("user", "kimchy").field("postDate", new Date()).field("message", "another post").endObject()));BulkResponse bulkResponse = bulkRequest.get();
if (bulkResponse.hasFailures()) {// process failures by iterating through each bulk response item
}
这篇关于Elasticsearch java API (11)Bulk API的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!