Riz
Riz

Reputation: 1065

Elasticsearch find where field has a specific value

I have a document in elastic search that looks like below

{
  "group1: {
     "status": "passed",
     "name": "abc"
     "group2": {
       "group3": {
         "status": "failed"
       }
     }
  }
}

I want to do a query to find documents where the key "status" in the docuument is failed. How can i do this without having to give the complete path to each status field? ie. group1.status and group1.group2.group3.status

Is something like "*.status" available?

Upvotes: 1

Views: 238

Answers (1)

Ryadh Khsib
Ryadh Khsib

Reputation: 94

Multi match supports wildcard field name selection:

GET /_search
{
  "query": {
    "multi_match": {
      "query": "failed",
      "fields": [
        "*.status"
      ]
    }
  }
}

Upvotes: 1

Related Questions