-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix broken parent and child aggregator #63811
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 0 additions & 24 deletions
24
modules/parent-join/src/test/resources/rest-api-spec/test/40_unconfigred.yml
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
modules/parent-join/src/yamlRestTest/resources/rest-api-spec/test/40_aggregations.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
setup: | ||
- do: | ||
indices.create: | ||
index: test | ||
body: | ||
settings: | ||
number_of_shards: 2 #Two shards proves that we route properly | ||
mappings: | ||
properties: | ||
join_field: { "type": "join", "relations": { "parent": "child", "child": "grand_child" } } | ||
id: { "type": "keyword" } | ||
|
||
- do: | ||
bulk: | ||
index: test | ||
refresh: true | ||
body: | ||
- '{ "index": {"_id": "1"}}' | ||
- '{ "tag": "bump", "join_field": { "name": "parent" } }' | ||
- '{ "index": {"_id": "2"}}' | ||
- '{ "tag": "jumble", "join_field": { "name": "parent" } }' | ||
- '{ "index": {"_id": "3", "routing": "1"}}' | ||
- '{ "animal": "dog", "join_field": { "name": "child", "parent": "1" } }' | ||
- '{ "index": {"_id": "4", "routing": "1"}}' | ||
- '{ "animal": "cat", "join_field": { "name": "child", "parent": "1" } }' | ||
- '{ "index": {"_id": "5", "routing": "2"}}' | ||
- '{ "animal": "dog", "join_field": { "name": "child", "parent": "2" } }' | ||
- '{ "index": {"_id": "6", "routing": "1"}}' | ||
- '{ "join_field": { "name": "grand_child", "parent": "5" } }' | ||
|
||
--- | ||
unconfigured: | ||
- do: | ||
index: | ||
index: test_unconfigured | ||
refresh: true | ||
body: | ||
join: | ||
name: question | ||
body: <p>I have Windows 2003 server and i bought a new Windows 2008 server..., | ||
title: Whats the best way to file transfer my site from server to a newer one?, | ||
tags: [windows-server-2003, windows-server-2008, file-transfer] | ||
|
||
- do: | ||
search: | ||
index: test_unconfigured | ||
body: | ||
size: 0 | ||
aggs: | ||
to-answers: | ||
children: | ||
type: answer | ||
- match: { hits.total.value: 1 } | ||
- match: { aggregations.to-answers.doc_count: 0 } | ||
|
||
--- | ||
children: | ||
- do: | ||
search: | ||
index: test | ||
body: | ||
size: 0 | ||
aggs: | ||
children: | ||
children: | ||
type: child | ||
- match: { hits.total.value: 6 } | ||
- match: { aggregations.children.doc_count: 3 } | ||
|
||
--- | ||
children containing cardinality: | ||
- do: | ||
search: | ||
index: test | ||
body: | ||
size: 0 | ||
aggs: | ||
children: | ||
children: | ||
type: child | ||
aggs: | ||
cardinality: | ||
cardinality: | ||
field: animal.keyword | ||
- match: { hits.total.value: 6 } | ||
- match: { aggregations.children.doc_count: 3 } | ||
- match: { aggregations.children.cardinality.value: 2 } | ||
|
||
--- | ||
parent: | ||
- do: | ||
search: | ||
index: test | ||
body: | ||
size: 0 | ||
aggs: | ||
parent: | ||
parent: | ||
type: child | ||
- match: { hits.total.value: 6 } | ||
- match: { aggregations.parent.doc_count: 2 } | ||
|
||
--- | ||
parent cardinality: | ||
- do: | ||
search: | ||
index: test | ||
body: | ||
size: 0 | ||
aggs: | ||
parent: | ||
parent: | ||
type: child | ||
aggs: | ||
cardinality: | ||
cardinality: | ||
field: tag.keyword | ||
- match: { hits.total.value: 6 } | ||
- match: { aggregations.parent.doc_count: 2 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -250,9 +250,12 @@ public SearchContext context() { | |
|
||
/** | ||
* Called after collection of all document is done. | ||
* <p> | ||
* Warning: this is not final only to allow the parent join aggregator | ||
* to delay this until building buckets. | ||
*/ | ||
@Override | ||
public final void postCollection() throws IOException { | ||
public void postCollection() throws IOException { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we'd be better off removing |
||
// post-collect this agg before subs to make it possible to buffer and then replay in postCollection() | ||
doPostCollection(); | ||
collectableSubAggregators.postCollection(); | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was borrowing this test setup and wanted to clean it up a bit while I was here.
bulk
is ever so slightly quicker for this sort of thing. And it takes up a lot fewer lines!