Hello All,
I just started with elastic search. I am using latest 5.4 version and rest client of it in Spring. Although I am successful to do uri search but I want to use request body search and below is my Code but it is givind total:0 and also given equivalent uri search which give me total:4 result. Please help me.
Request body Search code :=
RestClient restClient = RestClient.builder(new HttpHost("localhost", 9200, "http")).build();
HttpEntity entity = new NStringEntity("{\n" +
" \"query\" : {\n" +
" \"term\" : { \"pdfData\" : \"ADMINISTRATOR\" }\n" +
" }\n" +
"}", ContentType.APPLICATION_JSON);
Response indexResponse = restClient.performRequest("POST",
"/cha/elasticSearch/_search?pretty",Collections.<String, String>emptyMap(),entity);
System.out.println(EntityUtils.toString(indexResponse.getEntity()));
restClient.close();
uri search code :=
RestClient restClient = RestClient.builder(new HttpHost("localhost", 9200)).build();
Response indexResponse = restClient.performRequest("GET","/agd/elasticSearch/_search?pretty&q=pdfData:ADMINISTRATOR",Collections.<String, String>emptyMap());
System.out.println(EntityUtils.toString(indexResponse.getEntity());
restClient.close();