# How to find docs that contain the exact specified terms

**URL:** <https://discuss.elastic.co/t/how-to-find-docs-that-contain-the-exact-specified-terms/295758>\
**Category:** Elasticsearch\
**Created:** [January 29, 2022, 5:05pm UTC](https://discuss.elastic.co/t/how-to-find-docs-that-contain-the-exact-specified-terms/295758 "2022-01-29T17:05:43Z")\
**Posts on this page:** 1\
**Showing post:** 13

<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:47am UTC](https://discuss.elastic.co/t/how-to-find-docs-that-contain-the-exact-specified-terms/295758/13 "2022-02-09T09:47:58Z")

</div>

Hi @Cholley_Alexandre ,

I found another solution.

> [@Filter terms aggregation on array field](https://discuss.elastic.co/t/filter-terms-aggregation-on-array-field/296627/3):
>
> I was not correct. I found a solution. GET /test-index/\_search { "query":{ "bool": { "filter":[{ "terms": { "authors": ["1", "2"] } }], "must\_not": [{ "regexp": { "authors": "~(1|2)" } }] } } }

If you don't mind duplication of 'A' or 'B',

```auto
GET /test_runtime/_search
{
  "query":{
    "bool": {
      "filter": [
        {"term": {"my-field": "A"}},
        {"term": {"my-field": "B"}}
      ],
      "must_not": [
        {
          "regexp": {
            "my-field": "~(A|B)"
          }
        }
      ]
    }
  }
}

```

will return what you want. If you want to distinguish duplication or order, you may need custom fingerprint strategy as before.

---

_[View the full topic](https://discuss.elastic.co/t/how-to-find-docs-that-contain-the-exact-specified-terms/295758)._
