I am trying to use elastic search for searching I am successful to search keyword using URI search using rest client but I am unable to search using request body search below is the code for requestbody search please suggest what i am doing wrong there.
RestClient restClient = RestClient.builder(new HttpHost("localhost", 9200, "http")).build();
HttpEntity entity = new NStringEntity("{\n" +
" \"query\" : {\n" +
" \"term\" : { \"chaData\" : \"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();