# Bucket Selector Aggregation to eliminate null buckets

**URL:** <https://discuss.elastic.co/t/bucket-selector-aggregation-to-eliminate-null-buckets/330943>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [April 27, 2023, 10:58am UTC](https://discuss.elastic.co/t/bucket-selector-aggregation-to-eliminate-null-buckets/330943 "2023-04-27T10:58:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Silver137](https://avatars.discourse-cdn.com/v4/letter/s/839c29/32.png) [@Silver137](https://discuss.elastic.co/u/Silver137)\
**Post date:** [April 27, 2023, 10:58am UTC](https://discuss.elastic.co/t/bucket-selector-aggregation-to-eliminate-null-buckets/330943/1 "2023-04-27T10:58:29Z")

</div>

I'm trying to use the Bucket Selector aggregation to eliminate Null values from other pipeline aggregations without success

First Try of null checking:

```auto
"bucket_filter": {
          "bucket_selector": {
            "buckets_path": {
              "var_1": "something_from_movong_fn",
              "var_2": "something_from_movong_fn_1",
              "var_3": "something_from_movong_fn_1"
            },
            "script": "params.var_1 != null"
          }
        }

```

But not works, null metric are present in result.

Second try, null safe access operator:

```auto
"bucket_filter": {
          "bucket_selector": {
            "buckets_path": {
              "var_1": "something_from_movong_fn",
              "var_2": "something_from_movong_fn_1",
              "var_3": "something_from_movong_fn_1"
            },
            "script": "params?.var_1 != null"
          }
        }

```

But fails null return again.

Third Try (Instance of check):

```auto
"bucket_filter": {
          "bucket_selector": {
            "buckets_path": {
              "var_1": "something_from_movong_fn",
              "var_2": "something_from_movong_fn_1",
              "var_3": "something_from_movong_fn_1"
            },
            "script": "params?.var_1 instanceof double"
          }
        }

```

But fails with or without null safe operator return null values.

Another Try:

```auto
"bucket_filter": {
          "bucket_selector": {
            "buckets_path": {
              "var_1": "something_from_movong_fn",
              "var_2": "something_from_movong_fn_1",
              "var_3": "something_from_movong_fn_1"
            },
            "script": "params?.var_1? instanceof double"
          }
        }

```

But fail no returns nothing.

How can filter the null values on the pipeline aggregation?

Many thanks !

---

<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:** [May 25, 2023, 10:58am UTC](https://discuss.elastic.co/t/bucket-selector-aggregation-to-eliminate-null-buckets/330943/2 "2023-05-25T10:58:52Z")

</div>

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