Add support for has_parent, has_child and parent_id queries #115
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implements #116
Adds support for remaining join queries: has_parent, has_child and parent_id (https://www.elastic.co/guide/en/elasticsearch/reference/current/joining-queries.html)
Changes to note:
join-queriesfile as Elasticsearch documentation groups it under join queriesScoreModeenum from inside nested query tojoin-queriesfile as has_parent and has_child use the same score modesJsonDslrather thanSearchDslso that they can be used for inner hits in parent and child querieshas_parent
Produces:
{ "query": { "has_parent": { "parent_type": "parent", "query": { "match_all": { } }, "min_children": 1, "max_children": 2, "score_mode": "max", "ignore_unmapped": true, "inner_hits": { "_source": [ "name" ], "size": 1, "name": "adfa", "sort": [ { "a": { "order": "DESC" } } ] } } } }has_child
Produces:
{ "query": { "has_child": { "type": "child", "query": { "match_all": { } }, "min_children": 1, "max_children": 2, "score_mode": "max", "ignore_unmapped": true, "inner_hits": { "_source": [ "name" ], "size": 1, "name": "adfa", "sort": [ { "a": { "order": "DESC" } } ] } } } }parent_id
Produces:
{ "query": { "parent_id": { "type": "child", "id": "123", "ignore_unmapped": true } } }