How to Filter Parent based on Children terms

I want to get those parent users where users not blocked particular user
Here is my mapping

{
	"properties": {
		"id": {
			"type": "keyword"
		},
	
		"username": {
			"type": "text",
			"fields": {
				"raw": {
					"type": "keyword",
					"index": false
				}
			}
		},
		"created_at": {
			"type": "date"
		},
		"updated_at": {
			"type": "date"
		},
		"type": {
			"type": "join",
			"relations": {
				"user": [
					"block"
				]
			}
		}
	}
}

My Query is

GET /trendings/movie/_search
{

  "size":2000,
  "query": {
    "bool": {
      "must": [
        {
          "term":{
            "type":"user"
          }
        },
        {
          "has_child": {
         
            "type": "block",
             "query":{
               "bool":{
                 "must_not": [
                   {
                     "terms":{
                       "id":["260"]
                     }
                   }
                 ]
               }
             }
          }
        }
      ]
    }
  }
}

but a parent that contains block user 260 is coming in result, is there any way to filter parent based on children must_not

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