Bucket script aggregation, do not return parameter values

Hi, I am running Elasticsearch version 7.10, and I use Elasticsearch Java Client version 8. I basically run some aggregations to calculate a bucket script. I have defined scripts on elasticsearch, and use them in my request by referring to parameter values. However, elasticsearch returns also the parameter values besides my desired script calculation. Since I have many script calculations in a response, the size becomes bigger than 100mb and I get http.max_content_length error. It is not possible for me to part my request for now, so I am looking for a way to ignore parameter values in my response. Here is how my response looks like:

"filter#x": {
            "date_histogram#x": {
                "buckets": [
                    {
                        "PARAM_1": {
                            "sum#value": {
                                "value": 738.0
                            },
                            "doc_count": 15
                        },
                        "PARAM_2": {
                            "sum#value": {
                                "value": 689.0
                            },
                            "doc_count": 15
                        },
                        "PARAM_3": {
                            "sum#value": {
                                "value": 745.0
                            },
                            "doc_count": 15
                        },
                        "RESPONSE_THAT_USES_PARAMS": {
                            "value": 73.8
                        },
                        "doc_count": 3000,
                        "key_as_string": "2023-12-31T22:00:00.000Z",
                        "key": 1704060000000
                    }
              ]
        }
}

I create the request creating multiple aggregation Map, for my params and also for my value. The script calculation gives error when I exclude my params aggregations from the request. Here is how my aggregation looks(aggregationMap includes params and script aggregations):

Aggregation.of(a -> a
                .dateHistogram(dhaBuilder.build())
                .aggregations(aggregationMap)
        );

Here is how I send the request:

return SubmitRequest.of(sr -> sr
                .size(0) // do not return any documents.
                .index(searchIndex)
                .query(boolQuery._toQuery())
                .aggregations(filterAggregations)
                .waitForCompletionTimeout(Time.of(t -> t.time("5s")))
                .keepOnCompletion(false) // Only store async searches that do not completed within the period.
//              .keepAlive(Time.of(t -> t.time("6h"))) // How long the result of this search should be available // Does not affect when keepOnCompletion is false.
        );

and here is a part of my request:

{
    "aggregations": {
        "agg_x": {
            "aggregations": {
                "2024-01-25_15:29:50.484...": {
                    "aggregations": {
                        "sum_x": {
                            "aggregations": {
                                "value": {
                                    "sum": {
                                        "field": "measurementValue"
                                    }
                                }
                            },
                            "filter": {
                                "term": {
                                    "measurementType": {
                                        "value": "x"
                                    }
                                }
                            }
                        },
                        "sum_y": {
                            "aggregations": {
                                "value": {
                                    "sum": {
                                        "field": "measurementValue"
                                    }
                                }
                            },
                            "filter": {
                                "term": {
                                    "measurementType": {
                                        "value": "y"
                                    }
                                }
                            }
                        },
                        "simple_value#x": {
                            "bucket_script": {
                                "buckets_path": {
                                    "x": "x.value",
                                    "y": "y.value",
                                },
                                "gap_policy": "skip",
                                "script": {
                                    "id": "script_id_here"
                                }
                            }
                        },
                        

How can I tell elasticsearch not to return parameter values in the response? Any help is appreciated.

Note: I recently updated my client from Java High Level Rest Client to newest one, In HLRC, I was using BucketScriptPipelineAggregationBuilder to build the aggregation at worked fine, it was not showing params aggregations. I could not find this class or something similar in the new client. I might have done something wrong while upgrading, please response regarding this.

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