I am using the Java client to query the Elasticsearch cluster. On querying, I get the result as a SearchResponse. From it, I get the aggregations as Aggregations agg = sr.getAggregations();. How do I print out the full result as JSON like the result which is got from cURL?
1 Answer
You just need to print the SearchResponse object, for example:
SearchResponse response = search.execute().actionGet();
log.debug("Response: {}", response);
you can do the same with SearchRequestBuilder:
SearchRequestBuilder search = client.prepareSearch(INDEX)...
log.debug("Search: {}", search);