# Bucket script aggregation, do not return parameter values

**URL:** <https://discuss.elastic.co/t/bucket-script-aggregation-do-not-return-parameter-values/351872>\
**Category:** Elasticsearch\
**Tags:** painless, async-search, aggregations\
**Created:** [January 26, 2024, 11:26am UTC](https://discuss.elastic.co/t/bucket-script-aggregation-do-not-return-parameter-values/351872 "2024-01-26T11:26:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mert\_Uygur](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mert_uygur/32/131087_2.png) [@Mert\_Uygur](https://discuss.elastic.co/u/Mert_Uygur)\
**Post date:** [January 26, 2024, 11:26am UTC](https://discuss.elastic.co/t/bucket-script-aggregation-do-not-return-parameter-values/351872/1 "2024-01-26T11:26:23Z")

</div>

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:

```auto
"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):

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

```

Here is how I send the request:

```auto
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:

```auto
{
    "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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 23, 2024, 11:26am UTC](https://discuss.elastic.co/t/bucket-script-aggregation-do-not-return-parameter-values/351872/2 "2024-02-23T11:26:28Z")

</div>

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