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


Java IndexRequestBuilder.execute方法代码示例

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


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

示例1: index

import org.elasticsearch.action.index.IndexRequestBuilder; //导入方法依赖的package包/类
@Override
public void index(String appid, ParaObject po) {
	if (po == null || StringUtils.isBlank(appid)) {
		return;
	}
	try {
		IndexRequestBuilder irb = client().prepareIndex(getIndexName(appid), getType(), po.getId()).
				setSource(ElasticSearchUtils.getSourceFromParaObject(po));
		ActionListener<IndexResponse> responseHandler = ElasticSearchUtils.getIndexResponseHandler();
		if (isAsyncEnabled()) {
			irb.execute(responseHandler);
		} else {
			responseHandler.onResponse(irb.execute().actionGet());
		}
		logger.debug("Search.index() {}", po.getId());
	} catch (Exception e) {
		logger.warn(null, e);
	}
}
 
开发者ID:Erudika,项目名称:para-search-elasticsearch,代码行数:20,代码来源:ElasticSearch.java

示例2: executeIndexRequest

import org.elasticsearch.action.index.IndexRequestBuilder; //导入方法依赖的package包/类
private void executeIndexRequest(final StreamInput streamInput, final IndexRequestBuilder builder) {
    builder.execute(wrap(res -> {
        processRequests(streamInput);
        // continue
    }, e -> {
        if (senderRequestRetryCount >= 0) {
            if (requestErrorCount > senderRequestRetryCount) {
                logger.error("[Sender][" + index + "][" + requestErrorCount + "] Failed to index [" + builder.request().index() + "]["
                        + builder.request().type() + "][" + builder.request().id() + "]", e);
                requestErrorCount = 0;
                writeError(requestPosition, builder.request(), wrap(r -> processRequests(streamInput), ex -> {
                    logger.warn("[Sender][" + index + "] Failed to store an error request.", ex);
                    processRequests(streamInput);
                }));
            } else {
                if (logger.isDebugEnabled()) {
                    logger.debug("[" + requestErrorCount + "] Failed to index [" + builder.request().index() + "]["
                            + builder.request().type() + "][" + builder.request().id() + "]", e);
                }
                requestErrorCount++;
                executeIndexRequest(streamInput, builder);
            }
        } else {
            IOUtils.closeQuietly(streamInput);
            retryWithError("Failed to index (" + builder.request() + ")", e);
            // retry
        }
    }));
}
 
开发者ID:codelibs,项目名称:elasticsearch-indexing-proxy,代码行数:30,代码来源:RequestSender.java

示例3: launchRequestSender

import org.elasticsearch.action.index.IndexRequestBuilder; //导入方法依赖的package包/类
private void launchRequestSender(final String index, final long filePosition, final long version,
        final ActionListener<Map<String, Object>> listener) {
    if (logger.isDebugEnabled()) {
        logger.debug("Launching RequestSender(" + index + ")");
    }
    final Map<String, Object> source = new HashMap<>();
    source.put(IndexingProxyPlugin.NODE_NAME, nodeName());
    source.put(IndexingProxyPlugin.FILE_POSITION, filePosition);
    source.put(IndexingProxyPlugin.TIMESTAMP, new Date());
    source.put(DOC_TYPE, "index");
    final IndexRequestBuilder builder =
            client.prepareIndex(IndexingProxyPlugin.INDEX_NAME, IndexingProxyPlugin.TYPE_NAME, index).setSource(source).setRefreshPolicy(RefreshPolicy.WAIT_UNTIL);
    if (version > 0) {
        builder.setVersion(version);
    } else {
        builder.setCreate(true);
    }
    builder.execute(wrap(res -> {
        if (res.getResult() == Result.CREATED || res.getResult() == Result.UPDATED) {
            final RequestSender sender = new RequestSender(settings, client, threadPool, namedWriteableRegistry, nodeName(), dataPath,
                    index, dataFileFormat, docSenderMap, logger);
            final RequestSender oldSender = docSenderMap.put(index, sender);
            if (oldSender != null) {
                oldSender.terminate();
            }
            threadPool.schedule(TimeValue.ZERO, Names.GENERIC, sender);
            listener.onResponse(source);
        } else {
            listener.onFailure(new ElasticsearchException("Failed to update .idxproxy index: " + res));
        }
    }, listener::onFailure));
}
 
开发者ID:codelibs,项目名称:elasticsearch-indexing-proxy,代码行数:33,代码来源:IndexingProxyService.java


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