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


Java Response.getEntity方法代码示例

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


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

示例1: ClientYamlTestResponse

import org.elasticsearch.client.Response; //导入方法依赖的package包/类
ClientYamlTestResponse(Response response) throws IOException {
    this.response = response;
    if (response.getEntity() != null) {
        String contentType = response.getHeader("Content-Type");
        this.bodyContentType = XContentType.fromMediaTypeOrFormat(contentType);
        try {
            byte[] bytes = EntityUtils.toByteArray(response.getEntity());
            //skip parsing if we got text back (e.g. if we called _cat apis)
            if (bodyContentType != null) {
                this.parsedResponse = ObjectPath.createFromXContent(bodyContentType.xContent(), new BytesArray(bytes));
            }
            this.body = bytes;
        } catch (IOException e) {
            EntityUtils.consumeQuietly(response.getEntity());
            throw e;
        }
    } else {
        this.body = null;
        this.bodyContentType = null;
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:ClientYamlTestResponse.java

示例2: perform

import org.elasticsearch.client.Response; //导入方法依赖的package包/类
public SearchResult perform() {
  try {
    ObjectMapper mapper = new ObjectMapper();
    String queryString = serialize();
    LOG.info("Query: " + queryString);
    Response response = elasticSearchService.getRestClient().performRequest(
            "GET",
            "/" + index + "/_search",
            Collections.<String, String>emptyMap(),
            new StringEntity(queryString, "UTF-8"));

    HttpEntity entity = response.getEntity();
    return mapper.readValue(entity.getContent(), SearchResult.class);
  }
  catch (IOException ex) {
    LOG.error("Could not perform query", ex);
  }
  return null;
}
 
开发者ID:deveth0,项目名称:elasticsearch-aem,代码行数:20,代码来源:Search.java

示例3: rootRequest

import org.elasticsearch.client.Response; //导入方法依赖的package包/类
public HttpEntity rootRequest() throws IOException {
	Response response = restClient.performRequest(
			  "GET", "/",
			  Collections.singletonMap("pretty", "true"));
	// System.out.println(EntityUtils.toString(response.getEntity()));
	return response.getEntity();
}
 
开发者ID:pkiraly,项目名称:metadata-qa-marc,代码行数:8,代码来源:MarcElasticsearchClient.java

示例4: refreshIndexes

import org.elasticsearch.client.Response; //导入方法依赖的package包/类
public void refreshIndexes(String... names) {
    try {
        String endpoint = "/_refresh";
        if (names.length > 0) {
            endpoint = "/" + String.join(",", names) + endpoint;
        }

        Response response = client.performRequest(
                "POST",
                endpoint
        );

        if (response.getStatusLine().getStatusCode() > 399 && logger.isWarnEnabled()) {
            logger.warn("Problem while refreshing indexes: {}", String.join(",", names));
        }

        if (logger.isDebugEnabled()) {
            HttpEntity entity = response.getEntity();

            RefreshResponse refreshResponse = jacksonObjectMapper.readValue(entity.getContent(), RefreshResponse.class);
            Shards shards = refreshResponse.getShards();
            logger.debug("Shards refreshed: total {}, successfull {}, failed {}", shards.getTotal(), shards.getSuccessful(), shards.getFailed());
        }
    } catch (IOException e) {
        logger.warn("Problem while executing refresh request.", e);
        throw new ClusterApiException("Error when refreshing indexes." + e.getMessage());
    }

}
 
开发者ID:luminis-ams,项目名称:elastic-rest-spring-wrapper,代码行数:30,代码来源:IndexService.java

示例5: checkClusterHealth

import org.elasticsearch.client.Response; //导入方法依赖的package包/类
/**
 * Returns the current health of the cluster as a {@link ClusterHealth} object.
 *
 * @return ClusterHealth containing the basic properties of the health of the cluster
 */
public ClusterHealth checkClusterHealth() {
    try {
        Response response = client.performRequest(GET, "/_cluster/health");

        HttpEntity entity = response.getEntity();

        return jacksonObjectMapper.readValue(entity.getContent(), ClusterHealth.class);

    } catch (IOException e) {
        logger.warn("Problem while executing request.", e);
        throw new ClusterApiException("Error when checking the health of the cluster");
    }
}
 
开发者ID:luminis-ams,项目名称:elastic-rest-spring-wrapper,代码行数:19,代码来源:ClusterService.java

示例6: asMap

import org.elasticsearch.client.Response; //导入方法依赖的package包/类
public static Map<String, Object> asMap(Response response) {
    try {
        if (response.getEntity() == null) {
            return null;
        }
        return asMap(response.getEntity().getContent());
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:dadoonet,项目名称:elasticsearch-beyonder,代码行数:11,代码来源:JsonUtil.java

示例7: ElasticsearchResponse

import org.elasticsearch.client.Response; //导入方法依赖的package包/类
public ElasticsearchResponse(Response response) throws IOException {
    this.statusLine = response.getStatusLine();
    if (response.getEntity() != null) {
        this.entity = parseResponse(response);
    }
}
 
开发者ID:Talend,项目名称:components,代码行数:7,代码来源:ElasticsearchResponse.java


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