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


Java MultiGetItemResponse.isFailed方法代码示例

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


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

示例1: findDocuments

import org.elasticsearch.action.get.MultiGetItemResponse; //导入方法依赖的package包/类
/**
 * Find a set of documents.
 *
 * @param ids          The unique IDs of the documents you wish to find.
 * @param index        The index in which the document exists in Elasticsearch.
 * @param documentType The document type in Elasticsearch for this document.
 * @param javaType     The concrete java type the document represents.
 */
final protected <T extends IDocument> IPage<T> findDocuments(Set<String> ids, String index, String documentType, Class<T> javaType) {
    MultiGetResponse response = this.getClient().prepareMultiGet().add(index, documentType, ids).execute().actionGet();

    List<T> results = Lists.newArrayListWithCapacity(ids.size());
    for (MultiGetItemResponse item : response.getResponses()) {
        if (item.isFailed()) {
            throw new SearchServiceException("Unexpected failure while searching for documents.");
        }
        results.add(this.getDocumentFromSearchResponse(item.getResponse(), javaType));
    }

    IPage page = Page.of(results);
    page.setPageSize(results.size());
    page.setPageNumber(1);
    page.setTotalElements(results.size());

    return page;
}
 
开发者ID:bpatters,项目名称:eservice,代码行数:27,代码来源:AbstractElasticsearchDAO.java

示例2: queryForObjects

import org.elasticsearch.action.get.MultiGetItemResponse; //导入方法依赖的package包/类
/**
 * http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-multi-get.html
 * @param clzz
 * @param ids
 * @return
 */
public <T> List<T> queryForObjects(Class<T> clzz, String... ids) throws SearchException {
       String typeName = this.getTypeNameFromClass(clzz);
       Timer.Context timer = searchMetrics.indexTimer(typeName, "queryForObjects");
	try {
		MultiGetRequestBuilder request = client.prepareMultiGet();
		request.add(indexName, typeName, ids);
		MultiGetResponse response = request.execute().actionGet();
		List<T> results = new ArrayList<T>();
		for(MultiGetItemResponse resp : response.getResponses()){
			if(!resp.isFailed()){
				T o = this.docMapper.asObject(clzz, resp.getResponse().getSourceAsString());
				results.add(o);
			}
		}
           searchMetrics.indexIncr(typeName, "queryForObjects");
		return results;
	} catch (Exception e) {
           searchMetrics.failedIncr(typeName, "queryForObjects", e);
           logger.error("queryForObjects Error. ", e);
           throw new SearchException("queryForObjects Error. typeName="+typeName+", ids="+ids, e);
	}finally {
           timer.stop();
       }
   }
 
开发者ID:yamingd,项目名称:argo,代码行数:31,代码来源:ElasticSearchTemplate.java

示例3: mapResults

import org.elasticsearch.action.get.MultiGetItemResponse; //导入方法依赖的package包/类
@Override
public <T> LinkedList<T> mapResults(MultiGetResponse responses, Class<T> clazz) {
	LinkedList<T> list = new LinkedList<T>();
	for (MultiGetItemResponse response : responses.getResponses()) {
		if (!response.isFailed() && response.getResponse().isExists()) {
			T result = mapEntity(response.getResponse().getSourceAsString(), clazz);
			setPersistentEntityId(result, response.getResponse().getId(), clazz);
			list.add(result);
		}
	}
	return list;
}
 
开发者ID:uckefu,项目名称:uckefu,代码行数:13,代码来源:UKResultMapper.java

示例4: flush

import org.elasticsearch.action.get.MultiGetItemResponse; //导入方法依赖的package包/类
private void flush() {
    MultiGetResponse multiGetItemResponse = request.execute().actionGet();

    for(MultiGetItemResponse response : multiGetItemResponse.getResponses()) {
        if (response.isFailed()) {
            logger.error("Get failed: " + response.getFailure().getMessage());
        }

        Metric metric = request.metrics.get(response.getId());
        if (response.isFailed() || !response.getResponse().isExists()) {
            final String[] parts = metric.getPath().split("\\.");
            final StringBuilder sb = new StringBuilder();

            for (int i = 0; i < parts.length; i++) {
                if (sb.toString().length() > 0) {
                    sb.append(".");
                }
                sb.append(parts[i]);
                try {
                    bulkProcessor.add(new IndexRequest(index, type, metric.getTenant() + "_" + sb.toString()).source(
                            XContentFactory.jsonBuilder().startObject()
                                    .field("tenant", metric.getTenant())
                                    .field("path", sb.toString())
                                    .field("depth", (i + 1))
                                    .field("leaf", (i == parts.length - 1))
                                    .endObject()
                    ));
                } catch (IOException e) {
                    logger.error(e);
                }

            }

        }

    }

    request = new MetricMultiGetRequestBuilder(client, index, type);
}
 
开发者ID:EinsamHauer,项目名称:disthene,代码行数:40,代码来源:IndexThread.java

示例5: syncAcl

import org.elasticsearch.action.get.MultiGetItemResponse; //导入方法依赖的package包/类
private void syncAcl(OpenshiftRequestContext context) {
    LOGGER.debug("Syncing the ACL to ElasticSearch");
    try {
        lock.lock();
        LOGGER.debug("Loading SearchGuard ACL...");

        final MultiGetRequest mget = new MultiGetRequest();
        mget.putHeader(ConfigConstants.SG_CONF_REQUEST_HEADER, "true"); //header needed here
        mget.refresh(true);
        mget.realtime(true);
        mget.add(searchGuardIndex, SEARCHGUARD_ROLE_TYPE, SEARCHGUARD_CONFIG_ID);
        mget.add(searchGuardIndex, SEARCHGUARD_MAPPING_TYPE, SEARCHGUARD_CONFIG_ID);

        SearchGuardRoles roles = null;
        SearchGuardRolesMapping rolesMapping = null;
        MultiGetResponse response = client.multiGet(mget).actionGet();
        for (MultiGetItemResponse item : response.getResponses()) {
            if(!item.isFailed()) {
                if(LOGGER.isDebugEnabled()){
                    LOGGER.debug("Read in {}: {}", item.getType(), XContentHelper.convertToJson(item.getResponse().getSourceAsBytesRef(), true, true));
                }
                switch (item.getType()) {
                case SEARCHGUARD_ROLE_TYPE:
                    roles = new SearchGuardRoles().load(item.getResponse().getSource());
                    break;
                case SEARCHGUARD_MAPPING_TYPE:
                    rolesMapping = new SearchGuardRolesMapping().load(item.getResponse().getSource());
                    break;
                }
            }else {
                LOGGER.error("There was a failure loading document type {}", item.getFailure(), item.getType());
            }
        }

        if(roles == null || rolesMapping == null) {
            return;
        }

        LOGGER.debug("Syncing from cache to ACL...");
        RolesMappingSyncStrategy rolesMappingSync = documentFactory.createRolesMappingSyncStrategy(rolesMapping);
        rolesMappingSync.syncFrom(cache);
        
        RolesSyncStrategy rolesSync = documentFactory.createRolesSyncStrategy(roles);
        rolesSync.syncFrom(cache);

        writeAcl(roles, rolesMapping);
    } catch (Exception e) {
        LOGGER.error("Exception while syncing ACL with cache", e);
    } finally {
        lock.unlock();
    }
}
 
开发者ID:fabric8io,项目名称:openshift-elasticsearch-plugin,代码行数:53,代码来源:DynamicACLFilter.java


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