I am going to ask the same question again Convert SearchResponse to JsonObject
Actually I am using the same solution as mentioned in this question. But this solution is not working for me.
Below is my Elastic query:
AggregationBuilder aggregation = AggregationBuilders
.terms("users")
.field("USER")
.size(10)
SearchResponse res = client.prepareSearch(_index)
.setSize(0)
.addAggregation(aggregation)
.execute()
.actionGet();
But when I try to convert it into a JSON object
JSONObject SRJSON = new JSONObject(res.toString());
It is saying
Constructor JSONObject(String) undefined
Remove argument to match JSONObject()
And I am using below maven plugin and elastic vs ~2.3:
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>