本文整理匯總了Java中org.elasticsearch.action.index.IndexResponse.toString方法的典型用法代碼示例。如果您正苦於以下問題:Java IndexResponse.toString方法的具體用法?Java IndexResponse.toString怎麽用?Java IndexResponse.toString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.elasticsearch.action.index.IndexResponse
的用法示例。
在下文中一共展示了IndexResponse.toString方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: insert
import org.elasticsearch.action.index.IndexResponse; //導入方法依賴的package包/類
public String insert(String index,String type,Object json){
try {
if(client==null){
init();
}
IndexResponse response = client.prepareIndex(index, type).setSource(JSON.parseObject(JSON.toJSONString(json)),XContentType.JSON).execute().actionGet();
if(response.getResult().equals(Result.CREATED)){
System.out.println(JSON.toJSONString(response));
}
return response.toString();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
示例2: indexObject
import org.elasticsearch.action.index.IndexResponse; //導入方法依賴的package包/類
/**
* Adds (indexes) a given object to the given index with the given type
* @param object to index which should have a toString() method returning valid JSON
* @param index to add the object to
* @param type to give the object
* @return
*/
private String indexObject(Object object, String index, String type) {
IndexResponse response = elasticsearch
.prepareIndex(index, type)
.setSource(object.toString())
.get();
return response.toString();
}
示例3: indexTick
import org.elasticsearch.action.index.IndexResponse; //導入方法依賴的package包/類
/**
* put the given tick into elasticsearch
* @param tick the tick to be saved
* @return the toString() of the response from elasticsearch client
*/
@Override
public String indexTick(TickJson tick) {
logger.debug("indexTick:{}", tick.toString());
IndexResponse response = elasticsearch
.prepareIndex(indexForTicks, typeForTicks)
.setSource(tick.toString())
.get();
return response.toString();
}
示例4: indexIndicator
import org.elasticsearch.action.index.IndexResponse; //導入方法依賴的package包/類
@Override
public String indexIndicator(IndicatorJson indicator) {
logger.debug("indexIndicator:{}", indicator.toString());
IndexResponse response = elasticsearch
.prepareIndex(indexForIndicators, typeForIndicators)
.setSource(indicator.toString())
.get();
return response.toString();
}
示例5: indexStrategy
import org.elasticsearch.action.index.IndexResponse; //導入方法依賴的package包/類
@Override
public String indexStrategy(StrategyJson strategy) {
logger.debug("indexStrategy:{}", strategy.toString());
IndexResponse response = elasticsearch
.prepareIndex(indexForStrategies, typeForStrategies)
.setSource(strategy.toString())
.get();
return response.toString();
}
示例6: insert
import org.elasticsearch.action.index.IndexResponse; //導入方法依賴的package包/類
public String insert(String index,String type,Object json){
try {
if(xclient==null){
init();
}
// XContentBuilder builder = XContentFactory.jsonBuilder();
// builder.startObject();
// {
// builder.field("user", "kimchy");
// builder.field("postDate", new Date());
// builder.field("message", "trying out Elasticsearch");
// }
// builder.endObject();
IndexRequest request = new IndexRequest(index, type);
request.source(JSON.parseObject(JSON.toJSONString(json)),XContentType.JSON);
IndexResponse response = xclient.index(request);
// String _index = response.getIndex();
// String _type = response.getType();
// String id = response.getId();
// long version = response.getVersion();
// if (response.getResult() == DocWriteResponse.Result.CREATED) {
//
// } else if (response.getResult() == DocWriteResponse.Result.UPDATED) {
//
// }
// ReplicationResponse.ShardInfo shardInfo = response.getShardInfo();
// if (shardInfo.getTotal() != shardInfo.getSuccessful()) {
//
// }
// if (shardInfo.getFailed() > 0) {
// for (ReplicationResponse.ShardInfo.Failure failure : shardInfo.getFailures()) {
// String reason = failure.reason();
// }
// }
return response.toString();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}