# Use static data as a "pseudo-aggregation" in Elasticsearch query?

**URL:** <https://discuss.elastic.co/t/use-static-data-as-a-pseudo-aggregation-in-elasticsearch-query/164258>\
**Category:** Elasticsearch\
**Created:** [January 15, 2019, 8:01am UTC](https://discuss.elastic.co/t/use-static-data-as-a-pseudo-aggregation-in-elasticsearch-query/164258 "2019-01-15T08:01:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marc\_Zahn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marc_zahn/32/44302_2.png) [@Marc\_Zahn](https://discuss.elastic.co/u/Marc_Zahn)\
**Post date:** [January 15, 2019, 8:01am UTC](https://discuss.elastic.co/t/use-static-data-as-a-pseudo-aggregation-in-elasticsearch-query/164258/1 "2019-01-15T08:01:03Z")

</div>

Hi,

I have a quite simple question: Since I need some data in an aggregation for filtering documents I need some static data that I can use for comparing to other values. Somehow like this:

```
...
"group_by_sth": {
    "terms": ...group by sth...
},
"aggs": {
    "filter_sth": {
       "bucket_selector": {
          "buckets_path": {
             "std_upper": "stats.std_upper",
             "static_value": "my_static_data.id_sth"
          },
          "script": "params.question_avg < params.std_upper"
       }
    },
    "my_static_data": {
      "<some agg which contains static data>": {
        "id1": {...},
        "id2": {...},
        ...
      }
    },
...

```

where sth\_id is the id of the document which is group by sth. The background is that the data which is static is not available in this aggregation.

---

<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 12, 2019, 8:01am UTC](https://discuss.elastic.co/t/use-static-data-as-a-pseudo-aggregation-in-elasticsearch-query/164258/2 "2019-02-12T08:01:08Z")

</div>

Closed on February 12, 2019, 8:01am UTC

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