I am trying to fetch data from index using java API to generate a report using jasper reports.
I have added the maven dependency and able to make connection to ES.
While trying to fetch the data corresponding to the particular index, I am able to get the response when i pass the Index value, _type and _id in the request.
But I need to get all the data pertaining to that idex, so I am passing the Index value alone in the request, but I getting the below error:
Exception in thread "main" org.elasticsearch.action.ActionRequestValidationException: Validation Failed: 1: id is missing;
at org.elasticsearch.action.ValidateActions.addValidationError(ValidateActions.java:26)
at org.elasticsearch.action.get.GetRequest.validate(GetRequest.java:133)
at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1420)
at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1394)
at org.elasticsearch.client.RestHighLevelClient.get(RestHighLevelClient.java:714)
Below is my piece of code:
GetRequest getPersonRequest = new GetRequest("INDEX");`
RequestOptions requestOptions = RequestOptions.DEFAULT;
GetResponse getResponse = null;
try {
getResponse = client.get(getPersonRequest,requestOptions);
System.out.println("Returned value = " + getResponse.getSourceAsMap`Preformatted text`());
} catch (java.io.IOException e){
e.getLocalizedMessage();
}