Not getting whole response when I search using java api client

I am using below code to search using java api client,
SearchResponse searchResponse = esClient.search(searchRequest,Object.class);

When I test it using postman - I am getting below response
{"took":4,"timed_out":false,"_shards":{"failed":0.0,"successful":6.0,"total":6.0,"skipped":0.0},"hits":{"total":{"relation":"gte","value":10000},"here many lines of response
and at the end "....."
It doesn't show whole response with all closing brackets.
Please assist

What "whole response" are you expecting to see?
What is the complete code?

I mean when I run below query in Kibana I am getting response
{
"aggregations": {
"terms": {
"aggregations": {
"terms": {
"terms": {
"field": "",
"order": [
{
"_count": "desc"
},
{
"_key": "asc"
}
],
"size": 5
}
}
},
"date_histogram": {
"extended_bounds": {
"max": "2024-04-03T18:50:00Z",
"min": "2022-01-03T18:50:00Z"
},
"field": "createTime",
"fixed_interval": "7d",
"min_doc_count": 0
}
}
},
"from": 0,
"query": {
"bool": {
"must": [
{
"range": {
"createTime": {
"gte": "2022-01-03T18:50:00Z",
"lte": "2024-04-03T18:50:00Z"
}
}
}
]
}
},
"size": 0
}

if same query is being executed using java code (java api client)....it gives response but its getting cut off and only get first 10000 characters.
In my java code I am creating search request object with aggregations (on various conditions ) and then calling search method
SearchResponse searchResponse = esClient.search(searchRequest,Object.class);
When I print searchResponse using system out, I am getting first 10000 characters means partial response.

I think that's expected:

You still got the full response, it's just that you can't see it all by calling .toString().

if that is the case then why below code is throwing error

String data=data.replace("SearchResponse:", ""); //data is my search response from ES.I dont want word "SearchResponse:" which is being added in the response.
JsonNode dataObj = mapper.readTree(data);

and error I am getting is at JsonNode dataObj = mapper.readTree(data);
com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: was expecting closing quote for a string value.

Because you're converting the response to a string, truncating it in the process. So don't do that.

so you mean I should directly return SearchResponse object as a response of my REST api call?

I'm not sure what exactly you're trying to do here. You have a SearchResponse object, normally you would process it in some way, maybe iterating over its hits() or aggregations() properties.

Thanks for your info!
I had to use serialize method on my response object to get complete response which is more than 10k chars. Actually I am interested in aggregations property and it was more than 10k chars.

Ok, normally you wouldn't just serialize the response again (the client just put a bunch of effort into deserializing it for you) but it sounds like it's doing what you need now?

But I dont have any other option. I am interested in aggregations part of respons eobject but that is also more than 10k chars and I have to somehow put it in json so that my rest api (which in turn having logic to connect to ES , execute query and get response) will give me a response as a json

Are you saying that you want to just forward the data from Elasticsearch on exactly as ES sent it? You can do that by calling searchResponse.serialize(...), although it'd be a lot more efficient if you didn't even deserialize the response first, using org.elasticsearch.client.RestClient#performRequestAsync(org.elasticsearch.client.Request, org.elasticsearch.client.ResponseListener) directly.

I am using java api client and I am doing like this.

import co.elastic.clients.elasticsearch.core.SearchResponse;
SearchResponse searchResponse = esClient.search(searchRequest,void.class); //getting response

JsonpUtils.toJsonString(searchResponse , new JacksonJsonpMapper() //converting response to json string

Right, so either use org.elasticsearch.client.RestClient#performRequestAsync(org.elasticsearch.client.Request, org.elasticsearch.client.ResponseListener) instead of esClient.search, or else use searchResponse.serialize(...) instead of JsonpUtils.toJsonString(...).