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