About parent-child datatypes

Hello there! I was experimenting around parent-child relationships and I found interesting thing, but, I'd be glad if anyone would point out what needs to be done correctly.

Let's suppose we have an index with parent-child relationship, and we want to find parent with > different childs and different values though.

I try to build something like:

	"query": {
		"bool": {
			"must": [
				{
					"match": {"type": "url"}
				},
				{
					"match": {"isMain": false}
				},
				{
					"has_child": {
						"type": "child1",
						"query": {
							"bool": {
								"must": 
									{"match": { "cube.x": 0 }}
								
							}
						}
					}
				},
				{
					"has_child": {
						"type": "child1",
						"query": {
							"bool": {
								"must": {
									"match": {"cube.type": "FKU"}
								}
							}
						}
					}
				}
			]
		}
	}
}

But the result give me the same hits value as it was when I was trying to search criterias on one level. But when I did the query below, the result was correct. So, maybe I am mistaken, but was there done any improvement to such search queries?
Query:

	"query": {
		"bool": {
			"must": [
				{
					"match": {"type": "url"}
				},
				{
					"match": {"isMain": false}
				},
				{
					"has_child": {
						"type": "child1",
						"query": {
							"bool": {
								"must": {
									"match": { "cube.x": 0 }
								},
								"must_not": {
									"match": { "cube.type": "FKU" }
								}
							}
						}
					}
				},
				{
					"has_child": {
						"type": "child1",
						"query": {
							"bool": {
								"must_not": {
									"match": { "cube.x": 0 }
								},
								"must": {
									"match": { "cube.type": "FKU" }
								}
							}
						}
					}
				}
			]
		}
	}
}

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