elasticSearch 6.2 Query inside parent_id

Can anyone help how can I specify query inside parent_id query to filter out children who has match in their parent docs.
For e.g.
This is my parent
// "JOIN_FIELD": "group",
"GROUP_MEMBER": [
"1",
"2",
"3",
"4",
"5",
"6",
"7"
]

and my child
// "JOIN_FIELD": {
"name": "child",
"parent": "1"
}

Now I want to see child info a member say "3".
// "query": {
"bool": {
"filter": [
{
"terms": {
"GROUP_MEMBER": [
"3"
]
}
}

but I have no clue how to proceed with getting all child of this parent selected. I have read has_child supports query field but it is quite costly since it performs full join.

What elasticsearch, kibana, logstash versions are you using?
Are all you configurations correct?

I am using elasticsearch 6.2.4. Yes my all queries run well. I wish to know how to have filtration on children inside parent_id. Is there any way to do it currently or is it not at all supported?

Sorry, my previous answer was for some other question ( I have accidentally posted it here).

For your question - it is not very clear for me what you are trying to do. May be you can provide an expected output.

Do you mean that we you are running a parent_id query like this:


	"query": {
    "parent_id": {
			"type": "child",
			"id": "1"
		}
	}
}

you get a lot of children documents back for this parent with id=1, but you want only some of them?

Also, consider has child and has parent query types.

This is exactly what I mean, I do not want all children but some which meet some filter criteria (which I do not understand where to specify).
And this query will be used very frequently in my application and I believe hasParent and hasChild impact performance. Will this be a good decision to apply those queries?
Can I use post_filter here to filter out the children returned by parent_id. Can you guide me if I am thinking in right direction?

Can you just combine these two queries in a boolean query, something like this:

{
	"query": {
		"bool" : {
			"filter": {
				"term" : { "<your field>" : "<your search term>" }
			},
			"must" : {
				"parent_id": { "type": "child", "id": "1"}
			}
		}
	}
}

This sounds really cool. Thank you so much @mayya

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