How to find docs that contain the exact specified terms

Hi @Cholley_Alexandre ,

I found another solution.

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

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.

1 Like