# Filter terms aggregation on array field

**URL:** <https://discuss.elastic.co/t/filter-terms-aggregation-on-array-field/296627>\
**Category:** Elasticsearch\
**Created:** [February 8, 2022, 3:39pm UTC](https://discuss.elastic.co/t/filter-terms-aggregation-on-array-field/296627 "2022-02-08T15:39:45Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Tomo\_M](https://avatars.discourse-cdn.com/v4/letter/t/848f3c/32.png) [@Tomo\_M](https://discuss.elastic.co/u/Tomo_M)\
**Post date:** [February 9, 2022, 9:38am UTC](https://discuss.elastic.co/t/filter-terms-aggregation-on-array-field/296627/3 "2022-02-09T09:38:21Z")

</div>

I was not correct. I found a solution.

```auto
GET /test-index/_search
{
  "query":{
    "bool": {
      "filter":[{
        "terms": {
          "authors": [
            "1",
            "2"
          ]
        }
      }],
      "must_not": [
        {
          "regexp": {
            "authors": "~(1|2)"
          }
        }
      ]
    }
  }
}

```

> <https://stackoverflow.com/questions/38645755/negative-lookahead-regex-on-elasticsearch/38665819#38665819>

---

_[View the full topic](https://discuss.elastic.co/t/filter-terms-aggregation-on-array-field/296627)._
