forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix composite early termination on sorted (backport of elastic#72101)
I broke composite early termination when reworking how aggregations' contact for `getLeafCollector` around early termination in elastic#70320. We didn't see it in our tests because we weren't properly emulating the aggregation collection stage. This fixes early termination by adhering to the new contract and adds more tests. Closes elastic#72078 Co-authored-by: Benjamin Trent <[email protected]>
- Loading branch information
Showing
5 changed files
with
199 additions
and
6 deletions.
There are no files selected for viewing
179 changes: 179 additions & 0 deletions
179
...src/yamlRestTest/resources/rest-api-spec/test/search.aggregation/235_composite_sorted.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,179 @@ | ||
--- | ||
setup: | ||
- do: | ||
indices.create: | ||
index: sorted | ||
body: | ||
mappings: | ||
properties: | ||
date: | ||
type: date | ||
kw: | ||
type: keyword | ||
settings: | ||
index: | ||
number_of_shards: 1 | ||
number_of_replicas: 0 | ||
sort: | ||
field: date | ||
order: desc | ||
|
||
# Index single documents at a time and refresh. That'll create as many | ||
# segments as possible which has revealed bugs in the past. | ||
- do: | ||
index: | ||
index: sorted | ||
body: {"date": "2021-01-01T00:00:00.000Z", "kw": "cat"} | ||
refresh: true | ||
- do: | ||
index: | ||
index: sorted | ||
body: {"date": "2021-01-02T00:00:00.000Z", "kw": "cat"} | ||
refresh: true | ||
- do: | ||
index: | ||
index: sorted | ||
body: {"date": "2021-01-03T00:00:00.000Z", "kw": "cat"} | ||
refresh: true | ||
- do: | ||
index: | ||
index: sorted | ||
body: {"date": "2021-01-04T00:00:00.000Z", "kw": "cat"} | ||
refresh: true | ||
- do: | ||
index: | ||
index: sorted | ||
body: {"date": "2021-01-05T00:00:00.000Z", "kw": "cat"} | ||
refresh: true | ||
- do: | ||
index: | ||
index: sorted | ||
body: {"date": "2021-01-06T00:00:00.000Z", "kw": "cat"} | ||
refresh: true | ||
- do: | ||
index: | ||
index: sorted | ||
body: {"date": "2021-01-07T00:00:00.000Z", "kw": "cat"} | ||
refresh: true | ||
- do: | ||
index: | ||
index: sorted | ||
body: {"date": "2021-01-08T00:00:00.000Z", "kw": "cat"} | ||
refresh: true | ||
- do: | ||
index: | ||
index: sorted | ||
body: {"date": "2021-01-09T00:00:00.000Z", "kw": "not a cat"} | ||
refresh: true | ||
- do: | ||
index: | ||
index: sorted | ||
body: {"date": "2021-01-10T00:00:00.000Z", "kw": "also not a cat"} | ||
refresh: true | ||
|
||
--- | ||
one source - first page: | ||
- do: | ||
search: | ||
index: sorted | ||
body: | ||
size: 0 | ||
aggs: | ||
c: | ||
composite: | ||
size: 2 | ||
sources: | ||
- date: | ||
date_histogram: | ||
field: date | ||
calendar_interval: day | ||
format: iso8601 # Format makes the comparisons a little more obvious | ||
- length: { aggregations.c.buckets: 2 } | ||
- match: { aggregations.c.buckets.0.key.date: "2021-01-01T00:00:00.000Z" } | ||
- match: { aggregations.c.buckets.0.doc_count: 1 } | ||
- match: { aggregations.c.buckets.1.key.date: "2021-01-02T00:00:00.000Z" } | ||
- match: { aggregations.c.buckets.1.doc_count: 1 } | ||
|
||
--- | ||
one source - second page: | ||
- do: | ||
search: | ||
index: sorted | ||
body: | ||
size: 0 | ||
aggs: | ||
c: | ||
composite: | ||
size: 2 | ||
sources: | ||
- date: | ||
date_histogram: | ||
field: date | ||
calendar_interval: day | ||
format: iso8601 # Format makes the comparisons a little more obvious | ||
after: | ||
date: "2021-01-02T00:00:00.000Z" | ||
- length: { aggregations.c.buckets: 2 } | ||
- match: { aggregations.c.buckets.0.key.date: "2021-01-03T00:00:00.000Z" } | ||
- match: { aggregations.c.buckets.0.doc_count: 1 } | ||
- match: { aggregations.c.buckets.1.key.date: "2021-01-04T00:00:00.000Z" } | ||
- match: { aggregations.c.buckets.1.doc_count: 1 } | ||
|
||
--- | ||
two sources - first page: | ||
- do: | ||
search: | ||
index: sorted | ||
body: | ||
size: 0 | ||
aggs: | ||
c: | ||
composite: | ||
size: 2 | ||
sources: | ||
- date: | ||
date_histogram: | ||
field: date | ||
calendar_interval: day | ||
format: iso8601 # Format makes the comparisons a little more obvious | ||
- kw: | ||
terms: | ||
field: kw | ||
- length: { aggregations.c.buckets: 2 } | ||
- match: { aggregations.c.buckets.0.key.date: "2021-01-01T00:00:00.000Z" } | ||
- match: { aggregations.c.buckets.0.key.kw: cat } | ||
- match: { aggregations.c.buckets.0.doc_count: 1 } | ||
- match: { aggregations.c.buckets.1.key.date: "2021-01-02T00:00:00.000Z" } | ||
- match: { aggregations.c.buckets.1.key.kw: cat } | ||
- match: { aggregations.c.buckets.1.doc_count: 1 } | ||
|
||
--- | ||
two sources - second page: | ||
- do: | ||
search: | ||
index: sorted | ||
body: | ||
size: 0 | ||
aggs: | ||
c: | ||
composite: | ||
size: 2 | ||
sources: | ||
- date: | ||
date_histogram: | ||
field: date | ||
calendar_interval: day | ||
format: iso8601 # Format makes the comparisons a little more obvious | ||
- kw: | ||
terms: | ||
field: kw | ||
after: | ||
date: "2021-01-02T00:00:00.000Z" | ||
kw: cat | ||
- length: { aggregations.c.buckets: 2 } | ||
- match: { aggregations.c.buckets.0.key.date: "2021-01-03T00:00:00.000Z" } | ||
- match: { aggregations.c.buckets.0.key.kw: cat } | ||
- match: { aggregations.c.buckets.0.doc_count: 1 } | ||
- match: { aggregations.c.buckets.1.key.date: "2021-01-04T00:00:00.000Z" } | ||
- match: { aggregations.c.buckets.1.key.kw: cat } | ||
- match: { aggregations.c.buckets.1.doc_count: 1 } |
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
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