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
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.
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.
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.
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(...).
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.