# Noop Query

**URL:** <https://discuss.elastic.co/t/noop-query/340208>\
**Category:** Elasticsearch\
**Created:** [August 6, 2023, 8:03pm UTC](https://discuss.elastic.co/t/noop-query/340208 "2023-08-06T20:03:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yonzmeer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yonzmeer/32/124369_2.png) [@yonzmeer](https://discuss.elastic.co/u/yonzmeer)\
**Post date:** [August 6, 2023, 8:03pm UTC](https://discuss.elastic.co/t/noop-query/340208/1 "2023-08-06T20:03:11Z")

</div>

Hello,

I'm building a some-what generic converter from an object that contains lists of values, to a search requests for elasticsearch, for example:

```auto
{
    names: ["john", "bob"],
    cities: ["boston", "moscow"]
}

```

turns into

```auto
{
  "query": {
    "bool": {
      "must": [
        {
          "terms": {
            "name": [
              "john",
              "bob"
            ]
          }
        },
        {
          "terms": {
            "city": [
              "boston",
              "moscow"
            ]
          }
        }
      ]
    }
  },
  "size": 1000
}

```

My problem is, one of the lists could be empty, and a terms query without any terms returns no results:

```auto
{
  "terms": {
    "city": []
  }
}

```

I could use the `match_all` query, but sometimes the original query is meant to be negated, meanining the top `must` clouse will be replaced with `must_not` and then the internal `match_all` will be replaced with `match_none` which makes the code very tiresome.

I'm looking for a way to create a "noop" query to just be ignored.

Thanks a lot.

---

<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:** [September 3, 2023, 8:03pm UTC](https://discuss.elastic.co/t/noop-query/340208/2 "2023-09-03T20:03:24Z")

</div>

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