Elasticsearch filter two fields with full text match

{
  "query": {
    "bool": {
      "must" : [ 
        { "match": { "metadata.cloudAccountId": "462854006774" } },
        { "match": { "metadata.customerId": "3d472521-2a36-49d7-9080-5af57bf1af14" } },
      ]
    }
  } 
}

Here i wants to filter by two fields. And it is full text match. cloudAccountId working fine but, for customerId when i a changing anything from last part still it is working. How can i do must match so it will give result if the string is exact for both.

Upvotes: 0

Views: 495

Answers (1)

rabbitbr
rabbitbr

Reputation: 3271

If you want exact match use Term Query.

{
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "metadata.cloudAccountId": "462854006774"
          }
        },
         {
          "term": {
            "metadata.customerId": "3d472521-2a36-49d7-9080-5af57bf1af14"
          }
        }
      ]
    }
  } 
}

Upvotes: 0

Related Questions