--添加数据
IndexRequestBuilder requestBuilder = null;
requestBuilder = client.prepareIndex(index, type, key).setRefresh(false);
requestBuilder.setSource(value).get();
--批量数据
BulkRequestBuilder bulkRequest = null;
bulkRequest = client.prepareBulk();
for (Map.Entry<String, Object> map : doc.entrySet()) {
bulkRequest.add(client.prepareIndex(index, type, map.getKey())
.setSource(CouchbaseUtil.GJSON.toJson(map.getValue())).setRefresh(false));
}
bulkRequest.get();
bulkRequest.request().requests().clear();
--更新数据
client.prepareUpdate().setIndex(index).setType(type).setId(id).setDoc(map).get();
--批量删除数据
BulkRequestBuilder bulk = null;
bulk = client.prepareBulk();
for (String id : ids) {
bulk.add(client.prepareDelete().setIndex(index).setType(type).setId(id));
}
bulk.get();
IndexRequestBuilder requestBuilder = null;
requestBuilder = client.prepareIndex(index, type, key).setRefresh(false);
requestBuilder.setSource(value).get();
--批量数据
BulkRequestBuilder bulkRequest = null;
bulkRequest = client.prepareBulk();
for (Map.Entry<String, Object> map : doc.entrySet()) {
bulkRequest.add(client.prepareIndex(index, type, map.getKey())
.setSource(CouchbaseUtil.GJSON.toJson(map.getValue())).setRefresh(false));
}
bulkRequest.get();
bulkRequest.request().requests().clear();
--更新数据
client.prepareUpdate().setIndex(index).setType(type).setId(id).setDoc(map).get();
--批量删除数据
BulkRequestBuilder bulk = null;
bulk = client.prepareBulk();
for (String id : ids) {
bulk.add(client.prepareDelete().setIndex(index).setType(type).setId(id));
}
bulk.get();
[尊重社区原创,转载请保留或注明出处]
本文地址:http://elasticsearch.cn/article/83
本文地址:http://elasticsearch.cn/article/83