Elasticsearch combining Filter with Bool by a Must

I am trying to combine a "filter" with a "bool"/"should" inside a "must". The following query is automatically generated by an application (hence the nesting). How must the query look like to have an AND condition between the wildcard condition and the filter statement?

   "query":{
      "bool":{
         "filter": {
            "bool": {
              "must": [],
              "must_not": [],
              "should": [],
              "filter": {
                "bool": {
                  "should": [
                    {
                      "wildcard": {
                        "attachment.content_type.keyword": "video/*"
                      }
                    }
                  ],
                  "must": [],
                  "must_not": [],
                  "filter": [
                    {
                      "terms": {
                        "status.keyword": [
                          "xxx"
                        ]
                      }
                    }
                  ]
                }
              }
            }
          }
      }
   }

Having a hard time understanding what you are trying to do. In a boolean you usually want your "must", "must_not", or "should" to have something in them, and then a filter to help things along.

Without knowing more here's a possibility:

{
  "query": {
    "bool": {
      "filter": {
        "term": {
          "status.keyword": "xxx"
        }
      },
      "should": [
        {
          "wildcard": {
            "attachment.content_type.keyword": "video/*"
          }
        }
      ]
    }
  }
}

Will that return what you are looking for?

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