Bucket Script in Composite Aggregation using Java client 8.8.2

Java method should be written for the following ES query and I'm getting an error on script() function.

"AVERAGE": {
                    "bucket_script": {
                        "buckets_path": {
                            "SUM_TWO": "2ycc",
                            "SUM_RESEARCH": "roc"
                        },
                        "script": "params.SUM_TWO / params.SUM_RESEARCH"
                    }
                }

Map<String, String> dictionary = new HashMap<>();
        dictionary.put(field1, field2);
        dictionary.put(field1, field2);

        String scriptCode = "params.SUM_TWO / params.SUM_RESEARCH";

        return new Aggregation.Builder()
               .bucketScript(new BucketScriptAggregation.Builder().bucketsPath(new BucketsPath.Builder().dict(dictionary).build()).script(t -> t.inline(scriptCode))).build();

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