# Terms\_set within a nested query

**URL:** <https://discuss.elastic.co/t/terms-set-within-a-nested-query/218852>\
**Category:** Elasticsearch\
**Created:** [February 11, 2020, 7:28pm UTC](https://discuss.elastic.co/t/terms-set-within-a-nested-query/218852 "2020-02-11T19:28:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![edragom](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/edragom/32/65032_2.png) [@edragom](https://discuss.elastic.co/u/edragom)\
**Post date:** [February 11, 2020, 7:28pm UTC](https://discuss.elastic.co/t/terms-set-within-a-nested-query/218852/1 "2020-02-11T19:28:44Z")

</div>

Is it possible to use a terms\_set within a nested query? I haven't be able to find any examples or documentation. Various testing attempts have failed. Most recently it has looked like...

Mappings as...

```
{
  "mappings": {
    "things": {
      "properties": {
        "tags": {
          "type": "nested",
          "properties": {
            "name": { "type": "text" },
            "date": { "type": "date" }
          }
        }
      }
    }
  }
}

```

and part of the query as nested query as`

```
{'query':
    {'nested': {
        'path': 'tags',
        'query': {
            'bool': {
                'must': [{
                    'terms_set': {
                        'tags.name': {
                            'minimum_should_match_script': {'source': '2'},
                            'terms': ['test_one', 'test_two']}}
                        }, {
                    'range': {
                        'tags.date': {
                            'gte': '2020-01-01',
                            'lte': '2021-12-31'
                        }
                    }
                }]
            }
        }
    }}}

```

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:** [March 10, 2020, 7:28pm UTC](https://discuss.elastic.co/t/terms-set-within-a-nested-query/218852/2 "2020-03-10T19:28:51Z")

</div>

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