[PIT finder] return empty generator if first page is empty#171598
[PIT finder] return empty generator if first page is empty#171598pgayvallet merged 8 commits intoelastic:mainfrom
Conversation
|
@elasticmachine merge upstream |
|
@elasticmachine merge upstream |
| // do not yield first page if empty, unless there are aggregations | ||
| // (in which case we always want to return at least one page) | ||
| if (lastResultsCount > 0 || this.#findOptions.aggs) { | ||
| yield results; | ||
| } |
There was a problem hiding this comment.
Even if this is an edge case, it is possible to specify aggregations with a PIT search, and this is effectively done at least once in our code:
Note that this specific usage could be adapted (given there isn't any reason to use a PIT search here), but we scenario remains valid more globally, so we still have to check for aggregations and yield, otherwise there's no way for the API consumers to retrieve their aggregation results in case of empty hits.
There was a problem hiding this comment.
cc @elastic/fleet as you may want to adapt this snippet to use a standard SOR.find call instead of a PIT given you break on first page.
💚 Build Succeeded
Metrics [docs]
History
To update your PR or re-run it, just comment with: |
|
Pinging @elastic/kibana-core (Team:Core) |
Summary
Makes the PIT finder more consistent by ignoring empty first page and not yielding it (as this is also what is done for other pages)