# Help merging multiple filters

**URL:** <https://discuss.elastic.co/t/help-merging-multiple-filters/171370>\
**Category:** Elasticsearch\
**Created:** [March 7, 2019, 6:31pm UTC](https://discuss.elastic.co/t/help-merging-multiple-filters/171370 "2019-03-07T18:31:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chowpay](https://avatars.discourse-cdn.com/v4/letter/c/ee7513/32.png) [@chowpay](https://discuss.elastic.co/u/chowpay)\
**Post date:** [March 7, 2019, 6:31pm UTC](https://discuss.elastic.co/t/help-merging-multiple-filters/171370/1 "2019-03-07T18:31:24Z")

</div>

(Version: 6.4.2)  
I have 2 filters that work well : 1. Matches to the phrase "NA"

```
{
  "query": {
    "match": {
      "region.keyword": {
        "query": "NA",
        "type": "phrase"
      }
    }
  }
}

```

2.Uses a scripted field that pulls filters to show all hours not between 0-7:

```
{
  "script": {
    "script": {
      "inline": "boolean gte(Supplier s, def v) {return s.get() >= v} boolean lt(Supplier s, def v) {return s.get() < v}gte(() -> { doc['@timestamp'].date.hourOfDay }, params.gte) && lt(() -> { doc['@timestamp'].date.hourOfDay }, params.lt)",
      "params": {
        "gte": 0,
        "lt": 7,
        "value": ">=0 <7"
      },
      "lang": "painless"
    }
  }
}

```

I would like to group this into one filter so its "NA hours not between 0-7" this way I can change the region and the times and still apply additional filters.

Also not sure how to add this kind of custom filter as adding a filter only allows me to choose 1

---

<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:** [April 4, 2019, 6:31pm UTC](https://discuss.elastic.co/t/help-merging-multiple-filters/171370/2 "2019-04-04T18:31:27Z")

</div>

Closed on April 4, 2019, 6:31pm UTC

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