當前位置: 首頁>>代碼示例>>Java>>正文


Java MultiGetItemResponse.getResponse方法代碼示例

本文整理匯總了Java中org.elasticsearch.action.get.MultiGetItemResponse.getResponse方法的典型用法代碼示例。如果您正苦於以下問題:Java MultiGetItemResponse.getResponse方法的具體用法?Java MultiGetItemResponse.getResponse怎麽用?Java MultiGetItemResponse.getResponse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.elasticsearch.action.get.MultiGetItemResponse的用法示例。


在下文中一共展示了MultiGetItemResponse.getResponse方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: queryByMultiGet

import org.elasticsearch.action.get.MultiGetItemResponse; //導入方法依賴的package包/類
/**
 * 獲取多個對象(根據ID)
 *
 * @param transportClient
 * @throws IOException
 */
private static void queryByMultiGet(TransportClient transportClient) throws IOException {

	MultiGetResponse multiGetItemResponses = transportClient.prepareMultiGet()
			.add("product_index", "product", "1")
			.add("product_index", "product", "2")
			.add("product_index", "product", "3")
			.add("product_index", "product", "4")
			.add("product_index", "product", "5")
			.get();

	String resultJSON = null;
	for (MultiGetItemResponse multiGetItemResponse : multiGetItemResponses) {
		GetResponse getResponse = multiGetItemResponse.getResponse();
		if (getResponse.isExists()) {
			resultJSON = getResponse.getSourceAsString();
		}
	}
	logger.info("--------------------------------:" + resultJSON);
}
 
開發者ID:judasn,項目名稱:Elasticsearch-Tutorial-zh-CN,代碼行數:26,代碼來源:BaseDemo.java

示例2: getByIds

import org.elasticsearch.action.get.MultiGetItemResponse; //導入方法依賴的package包/類
@Override
public <T> List<T> getByIds(Class<T> clazz, List<String> ids) {
    String typeName = MappingProcessor.getIndexTypeName(clazz);
    if (logger.isDebugEnabled()) {
        logger.debug("Get objects by ids, class: {}, type: {}, ids: {}", clazz.getSimpleName(), typeName, ids);
    }
    MultiGetResponse responses = client.prepareMultiGet().add(getIndexName(), typeName, ids).get();
    List<T> results = new ArrayList<T>();
    if (responses != null) {
        for (MultiGetItemResponse response : responses) {
            if (response.getResponse() != null) {
                results.add(objectProcessor.fromJsonString(response.getResponse().getSourceAsString(), clazz));
            }
        }
    }
    return results;
}
 
開發者ID:kzwang,項目名稱:elasticsearch-osem,代碼行數:18,代碼來源:ElasticSearchSearcherImpl.java

示例3: existBulk

import org.elasticsearch.action.get.MultiGetItemResponse; //導入方法依賴的package包/類
public Set<String> existBulk(String indexName, String typeName, final Collection<String> ids) {
    if (ids == null || ids.size() == 0) return new HashSet<>();
    MultiGetResponse multiGetItemResponses = elasticsearchClient.prepareMultiGet()
            .add(indexName, typeName, ids)
            .get();
    Set<String> er = new HashSet<>();
    for (MultiGetItemResponse itemResponse : multiGetItemResponses) { 
        GetResponse response = itemResponse.getResponse();
        if (response.isExists()) {                      
            er.add(response.getId());
        }
    }
    return er;
}
 
開發者ID:yacy,項目名稱:yacy_grid_mcp,代碼行數:15,代碼來源:ElasticsearchClient.java

示例4: MultiGet

import org.elasticsearch.action.get.MultiGetItemResponse; //導入方法依賴的package包/類
private static void MultiGet(Client client) {

        MultiGetResponse response = client.prepareMultiGet()
                .add("twitter","tweet","2","1")
                .get();
        for(MultiGetItemResponse itemResponse:response){
            GetResponse getResponse = itemResponse.getResponse();
            if(getResponse.isExists()){
                System.out.println(getResponse.getSourceAsString());
            }
        }
    }
 
開發者ID:hs-web,項目名稱:hsweb-learning,代碼行數:13,代碼來源:ElasticSearch.java

示例5: name

import org.elasticsearch.action.get.MultiGetItemResponse; //導入方法依賴的package包/類
@Test
public void name() throws Exception {
    MultiGetResponse multiGetItemResponses = client.prepareMultiGet()
            .add("twitter", "tweet", "1")
            .add("twitter", "tweet", "2", "3", "4")
            .add("another", "type", "foo")
            .get();
    for (MultiGetItemResponse itemResponse : multiGetItemResponses) {
        GetResponse response = itemResponse.getResponse();
        if (response.isExists()) {
            String json = response.getSourceAsString();
        }
    }
}
 
開發者ID:felayman,項目名稱:elasticsearch-full,代碼行數:15,代碼來源:MultiGetDemo.java

示例6: findAll

import org.elasticsearch.action.get.MultiGetItemResponse; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public List<T> findAll(final List<String> ids) {
  if (ids.isEmpty()) {
    return ImmutableList.of();
  }

  final Builder<T> builder = ImmutableList.builder();

  final MultiGetResponse response = client
    .prepareMultiGet()
    .add(index, type, ids)
    .execute()
    .actionGet();

  for(final MultiGetItemResponse item : response.getResponses()) {
    final GetResponse get = item.getResponse();
    if(get.isSourceEmpty()) {
      continue;
    }

    final String json = get.getSourceAsString();
    final T entity = deserializer.apply(json);
    builder.add((T) entity.withId(get.getId()));
  }

  return builder.build();
}
 
開發者ID:jloisel,項目名稱:elastic-crud,代碼行數:29,代碼來源:ElasticSearchRepository.java

示例7: containsKibanaUserIndex

import org.elasticsearch.action.get.MultiGetItemResponse; //導入方法依賴的package包/類
private boolean containsKibanaUserIndex(ActionResponse response) {
    String index = "";

    if (response instanceof MultiGetResponse) {
        for (MultiGetItemResponse item : ((MultiGetResponse) response).getResponses()) {
            GetResponse itemResponse = item.getResponse();
            Failure itemFailure = item.getFailure();

            if (itemResponse == null) {
                if (isKibanaUserIndex(itemFailure.getIndex())) {
                    return true;
                }
            } else {
                if (isKibanaUserIndex(itemResponse.getIndex())) {
                    return true;
                }
            }
        }

        return false;
    }

    if (response instanceof IndexResponse) {
        index = ((IndexResponse) response).getIndex();
    } else if (response instanceof GetResponse) {
        index = ((GetResponse) response).getIndex();
    } else if (response instanceof DeleteResponse) {
        index = ((DeleteResponse) response).getIndex();
    } else if (response instanceof GetFieldMappingsResponse) {
        ImmutableMap<String, ImmutableMap<String, ImmutableMap<String, FieldMappingMetaData>>> mappings = ((GetFieldMappingsResponse) response)
                .mappings();
        for (String key : mappings.keySet()) {
            index = key;
        }
    }

    return isKibanaUserIndex(index);
}
 
開發者ID:fabric8io,項目名稱:openshift-elasticsearch-plugin,代碼行數:39,代碼來源:KibanaUserReindexAction.java

示例8: testMultiGet

import org.elasticsearch.action.get.MultiGetItemResponse; //導入方法依賴的package包/類
@Test
public void testMultiGet() {
    MultiGetResponse multiGetItemResponses = client.prepareMultiGet().add("twitter", "tweet", "1").add("twitter", "tweet", "2", "3", "4")
            .add("another", "type", "foo").get();

    for (MultiGetItemResponse itemResponse : multiGetItemResponses) {
        GetResponse response = itemResponse.getResponse();
        if (response.isExists()) {
            String json = response.getSourceAsString();
            System.out.println(json);
        }
    }
}
 
開發者ID:dzh,項目名稱:jframe,代碼行數:14,代碼來源:TestTransportClient.java


注:本文中的org.elasticsearch.action.get.MultiGetItemResponse.getResponse方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。