當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。