本文整理汇总了Java中org.elasticsearch.action.bulk.BulkResponse.toString方法的典型用法代码示例。如果您正苦于以下问题:Java BulkResponse.toString方法的具体用法?Java BulkResponse.toString怎么用?Java BulkResponse.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.action.bulk.BulkResponse
的用法示例。
在下文中一共展示了BulkResponse.toString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bulkDelete
import org.elasticsearch.action.bulk.BulkResponse; //导入方法依赖的package包/类
@Override
public String bulkDelete(String index, String type, String... ids) {
try {
if(client==null){
init();
}
BulkRequestBuilder bulkRequest = client.prepareBulk();
for (String id : ids) {
bulkRequest.add(client.prepareDelete(index, type, id));
}
BulkResponse result = bulkRequest.execute().get();
return result.toString();
}catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
示例2: bulkDelete
import org.elasticsearch.action.bulk.BulkResponse; //导入方法依赖的package包/类
public String bulkDelete(String index,String type,String... ids){
try {
if(xclient==null){
init();
}
BulkRequest request = new BulkRequest();
for (String id : ids) {
request.add(new DeleteRequest(index, type, id));
}
BulkResponse result = xclient.bulk(request);
return result.toString();
}catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
示例3: bulkUpsert
import org.elasticsearch.action.bulk.BulkResponse; //导入方法依赖的package包/类
public String bulkUpsert(String index,String type,List<Object> jsons){
try {
if(client==null){
init();
}
BulkRequestBuilder bulkRequest = client.prepareBulk();
for (Object json : jsons) {
JSONObject obj = JSON.parseObject(JSON.toJSONString(json));
String id = UUIDs.base64UUID();
if(obj.containsKey("id")){
id = obj.getString("id");
obj.remove("id");
bulkRequest.add(client.prepareUpdate(index, type, id).setDoc(obj.toJSONString(),XContentType.JSON));
}else{
bulkRequest.add(client.prepareIndex(index, type, id).setSource(obj.toJSONString(),XContentType.JSON));
}
}
BulkResponse result = bulkRequest.execute().get();
return result.toString();
}catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
示例4: bulkUpsert
import org.elasticsearch.action.bulk.BulkResponse; //导入方法依赖的package包/类
public String bulkUpsert(String index,String type,List<Object> jsons){
try {
if(xclient==null){
init();
}
BulkRequest request = new BulkRequest();
for (Object json : jsons) {
JSONObject obj = JSON.parseObject(JSON.toJSONString(json));
String id = UUIDs.base64UUID();
if(obj.containsKey("id")){
id = obj.getString("id");
obj.remove("id");
}
// if(obj.containsKey("id")){
// request.add(new UpdateRequest(index, type, id).doc(obj.toJSONString(),XContentType.JSON));
// }else{
// request.add(new IndexRequest(index, type).source(obj.toJSONString(),XContentType.JSON));
// }
request.add(new UpdateRequest(index, type, id).upsert(obj.toJSONString(),XContentType.JSON));
}
BulkResponse result = xclient.bulk(request);
return result.toString();
}catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
示例5: indexTicks
import org.elasticsearch.action.bulk.BulkResponse; //导入方法依赖的package包/类
/**
* put the given ticks into elasticsearch
* @param ticks the ticks to be saved
* @return the toString() of the response from elasticsearch client
*/
@Override
public String indexTicks(List<TickJson> ticks) {
Validate.notNull(ticks);
logger.info("indexTicks:{}", ticks.size());
BulkRequestBuilder bulk = elasticsearch.prepareBulk();
ticks.forEach(tick -> bulk.add(elasticsearch
.prepareIndex(indexForTicks, typeForTicks)
.setSource(tick.toString())));
BulkResponse response = bulk.get();
return response.toString();
}
示例6: indexIndicators
import org.elasticsearch.action.bulk.BulkResponse; //导入方法依赖的package包/类
@Override
public String indexIndicators(List<IndicatorJson> indicators) {
Validate.notNull(indicators);
logger.info("indexIndicators:{}", indicators.size());
BulkRequestBuilder bulk = elasticsearch.prepareBulk();
indicators.forEach(indicator -> bulk.add(elasticsearch
.prepareIndex(indexForIndicators, typeForIndicators)
.setSource(indicator.toString())));
BulkResponse response = bulk.get();
return response.toString();
}
示例7: indexStrategies
import org.elasticsearch.action.bulk.BulkResponse; //导入方法依赖的package包/类
@Override
public String indexStrategies(List<StrategyJson> strategies) {
Validate.notNull(strategies);
logger.info("indexStrategies:{}", strategies.size());
BulkRequestBuilder bulk = elasticsearch.prepareBulk();
strategies.forEach(strategy -> bulk.add(elasticsearch
.prepareIndex(indexForStrategies, typeForStrategies)
.setSource(strategy.toString())));
BulkResponse response = bulk.get();
return response.toString();
}