Help needed with MUST_NOT in a nested query

You can try something like

{
	"query" : {
		"bool" : {
			"must" : [
				{
					"bool" : {
						"should" : [
							{
								//match c2
							},
							{
								//match c3
							},
							{
								//match c4
							}
						]
					}
				},
				{
					"bool" : {
						"must_not" : [
							{
								"bool" : {
									"must" : [
										{
											//match c2
										},
										{
											//match c3
										},
										{
											//match c4
										}
									]
								}
							}
						]
					}
				}
			]
		}
	}
}
2 Likes