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


Java IndexResponse.getResult方法代码示例

本文整理汇总了Java中org.elasticsearch.action.index.IndexResponse.getResult方法的典型用法代码示例。如果您正苦于以下问题:Java IndexResponse.getResult方法的具体用法?Java IndexResponse.getResult怎么用?Java IndexResponse.getResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.action.index.IndexResponse的用法示例。


在下文中一共展示了IndexResponse.getResult方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: indexFact

import org.elasticsearch.action.index.IndexResponse; //导入方法依赖的package包/类
/**
 * Index a Fact into ElasticSearch.
 *
 * @param fact Fact to index
 * @return Indexed Fact
 */
public FactDocument indexFact(FactDocument fact) {
  if (fact == null || fact.getId() == null) return null;
  IndexResponse response;

  try {
    IndexRequest request = new IndexRequest(INDEX_NAME, TYPE_NAME, fact.getId().toString())
            .source(FACT_DOCUMENT_WRITER.writeValueAsBytes(encodeValues(fact)), XContentType.JSON);
    response = clientFactory.getHighLevelClient().index(request);
  } catch (IOException ex) {
    throw logAndExit(ex, String.format("Could not perform request to index Fact with id = %s.", fact.getId()));
  }

  if (response.status() != RestStatus.OK && response.status() != RestStatus.CREATED) {
    LOGGER.warning("Could not index Fact with id = %s.", fact.getId());
  } else if (response.getResult() == DocWriteResponse.Result.CREATED) {
    LOGGER.info("Successfully indexed Fact with id = %s.", fact.getId());
  } else if (response.getResult() == DocWriteResponse.Result.UPDATED) {
    LOGGER.info("Successfully re-indexed existing Fact with id = %s.", fact.getId());
  }

  return fact;
}
 
开发者ID:mnemonic-no,项目名称:act-platform,代码行数:29,代码来源:FactSearchManager.java

示例2: process

import org.elasticsearch.action.index.IndexResponse; //导入方法依赖的package包/类
@Override
public void process(ResultItems resultItems, Task task) {
    Iterator i$ = resultItems.getAll().entrySet().iterator();
    try {
        XContentBuilder xContentBuilder = jsonBuilder().startObject();
        while (i$.hasNext()) {
            Map.Entry entry = (Map.Entry) i$.next();
            xContentBuilder.field((String) entry.getKey(), entry.getValue());
        }
        String json = xContentBuilder.endObject().string();
        IndexResponse response = null;
        if (StringUtils.isNotBlank(resultItems.get("id"))) {
            response = client
                    .prepareIndex(INDEX_NAME, TYPE_NAME, resultItems.get("id"))
                    .setSource(json).get();
        } else {
            response = client
                    .prepareIndex(INDEX_NAME, TYPE_NAME)
                    .setSource(json).get();
        }
        if (response.getResult() != IndexResponse.Result.CREATED)
            LOG.error("索引失败,可能重复创建,resultItem:" + resultItems);
    } catch (IOException e) {
        LOG.error("索引出错," + e.getLocalizedMessage());
        e.printStackTrace();
    }
}
 
开发者ID:bruceq,项目名称:Gather-Platform,代码行数:28,代码来源:ESPipeline.java

示例3: insert

import org.elasticsearch.action.index.IndexResponse; //导入方法依赖的package包/类
public IndexResponse insert(final String index, final String type,
        final String id,
        final BuilderCallback<IndexRequestBuilder> builder) {
    final IndexResponse actionGet = builder
            .apply(client().prepareIndex(index, type, id)).execute()
            .actionGet();
    if (actionGet.getResult() != Result.CREATED) {
        onFailure("Failed to insert " + id + " into " + index + "/" + type
                + ".", actionGet);
    }
    return actionGet;
}
 
开发者ID:codelibs,项目名称:elasticsearch-cluster-runner,代码行数:13,代码来源:ElasticsearchClusterRunner.java


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