How to pass the raw aggregation query in JSON using REST HighLevelClient in E.S 5.6.9?

How do I pass raw json aggregation query to REST HighLevelClient in E.S 5.6.9?

For Example, Given the json below how do I pass the json below as is to the REST HighLevelClient?

    "aggs" : {
        "genres" : {
            "terms" : { "field" : "genre" }


providing json is not really what the high-level REST client is meant for, it's more to avoid having to deal with json. You may be able to achieve parsing that json into a temporary SearchSourceBuilder using its fromXContent method, then you can retrieve the aggs in object format using the aggregations getter and set them back to another SearchSourceBuilder instance, which I presume would have also other sections set (query etc.) using the aggregation setter.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.