为了账号安全,请及时绑定邮箱和手机立即绑定

ElasticSearch JavaAPI RestClient未给出响应

ElasticSearch JavaAPI RestClient未给出响应

烙印99 2021-04-13 17:22:48
我正在使用RestClient JavaAPI从弹性搜索中获取文档。但是没有收到我的请求的回复。正在使用形成我的请求QueryBuilder。请找到我的Java代码,该代码用于从弹性搜索中获取文档private final static String ATTACHMENT = "document_attachment";private final static String TYPE = "doc";static long BUFFER_SIZE = 520 * 1024 * 1024;   //  <---- set buffer to 120MB instead of 100MBpublic static void main(String args[]){    RestClient restClient = null;    Response contentSearchResponse=null;    try {    restClient = RestClient.builder(                    new HttpHost("localhost", 9200, "http"),                    new HttpHost("localhost", 9201, "http")).build();    } catch (Exception e) {        System.out.println(e.getMessage());    }    SearchRequest contentSearchRequest = new SearchRequest(ATTACHMENT);     SearchSourceBuilder contentSearchSourceBuilder = new SearchSourceBuilder();    contentSearchRequest.types(TYPE);    QueryBuilder attachmentQB = QueryBuilders.matchQuery("attachment.content", "activa");    contentSearchSourceBuilder.query(attachmentQB);    contentSearchSourceBuilder.size(50);    contentSearchRequest.source(contentSearchSourceBuilder);    System.out.println("Request --->"+contentSearchRequest.toString());    Map<String, String> params = Collections.emptyMap();    HttpEntity entity = new NStringEntity(contentSearchSourceBuilder.toString(), ContentType.APPLICATION_JSON);    HttpAsyncResponseConsumerFactory.HeapBufferedResponseConsumerFactory consumerFactory =            new HttpAsyncResponseConsumerFactory.HeapBufferedResponseConsumerFactory((int) BUFFER_SIZE);    System.out.println("Printing Entity---->"+entity.toString());    try {        contentSearchResponse = restClient.performRequest("GET", "/document_attachment/doc/_search", params, entity, consumerFactory);    } catch (IOException e1) {        e1.printStackTrace();    }     System.out.println("Entity Response --->"+contentSearchResponse.getEntity());    }请查找有关使用Sysout打印的我的“需求,实体和响应”的详细信息。
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 247 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信