Hi,
When trying to fetch data from elasticsearch using Java rest API, I am getting only the schema as JSON, and not the data.
Can you please help me.
Here is what I am doing:
RestClient restClient =
RestClient.builder(new HttpHost("localhost", 9200, "http")).build();
String query = "{\n" +
"\"query\": {\n" +
"\"bool\": {\n" +
"\"must\": [\n" +
" {\n" +
" \"match_all\": {}\n" +
" }\n" +
"]\n" +
"}\n" +
"}\n" +
"\"from\": 0,\n" +
"\"size\": 10" +
"}";
HttpEntity entity = new NStringEntity(
query, ContentType.APPLICATION_JSON);
Response contentResponse =
restClient.performRequest("GET", "/customers",
Collections.singletonMap("pretty", "true"), entity);
String contentResult = EntityUtils.toString(contentResponse.getEntity());
System.out.println("Content JSON : " + contentResult);
Please suggest.