当前位置: 首页>>代码示例>>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;未经允许,请勿转载。