当前位置: 首页>>代码示例>>Java>>正文


Java IndexResponse.toString方法代码示例

本文整理汇总了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;
}
 
开发者ID:dev-share,项目名称:css-elasticsearch,代码行数:17,代码来源:ElasticsearchTransportFactory.java

示例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();
}
 
开发者ID:the-james-burton,项目名称:the-turbine,代码行数:15,代码来源:ElasticsearchNativeServiceImpl.java

示例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();
}
 
开发者ID:the-james-burton,项目名称:the-turbine,代码行数:15,代码来源:ElasticsearchNativeServiceImpl.java

示例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();
}
 
开发者ID:the-james-burton,项目名称:the-turbine,代码行数:10,代码来源:ElasticsearchNativeServiceImpl.java

示例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();
}
 
开发者ID:the-james-burton,项目名称:the-turbine,代码行数:10,代码来源:ElasticsearchNativeServiceImpl.java

示例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;
	}
 
开发者ID:dev-share,项目名称:css-elasticsearch,代码行数:42,代码来源:ElasticsearchHighRestFactory.java


注:本文中的org.elasticsearch.action.index.IndexResponse.toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。