Skip to content
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

[Partial Results] Move other bucket into Search Source #96384

Merged
merged 34 commits into from
Apr 18, 2021

Conversation

lizozom
Copy link
Contributor

@lizozom lizozom commented Apr 7, 2021

Summary

Depends on #96241

When an aggregation has an other bucket, one or more post flight requests are needed to construct it.
Previously, that logic was part of the request handler code, making it available to expressions, but not to direct consumers of SearchSource.

This PR:

  • Allows passing an AggConfigs object into searchSource.setField('aggs', ...).
  • Removes the boolean parameter passed to aggConfigs.toDsl
  • Adds a hierarchical option to AggConfigs, replacing the previous parameter
  • Moves the handling of postFlightRequests into search source.

Response

The search observable returned from searchSource.fetch$() generally emits one or more responses (all but the last one being partial results). If the AggConfigs passed to the searchSource generate postFlightRequests, the searchSource will emit an additional single response (even if it required multiple calls), with the other bucket fully populated.

image

Release Note

Adds Other Bucket support to SearchSource, by passing in an AggConfigs object directly to searchSource.setField('aggs', aggs).

The search observable returned from searchSource.fetch$() will emit one or more responses (all but the last one being partial results). If the AggConfigs passed to the searchSource generate postFlightRequests, the searchSource will emit an additional single response (even if it required multiple calls), with the other bucket fully populated.

image

Tests

These changes effect any consumers of SearchSource, with or without the Other bucket, i.e. apps like Dashboard, Visualizations, Lens and Maps. Consumers of the lower level data.search API should not be effected by this PR.

Special attention should be given to testing the Other bucket, hierarchical parameter (formerly known as metricsAtAllLevels) and the behavior of the inspector in the above scenarios.

Unit tests

  • _terms_other_bucket_helper.test.ts
    • Added types
  • request_handler.test.ts
    • 'setField(aggs)' - adjust aggs type
    • 'calls searchSource.fetch' - adjust inspector format
    • 'calls agg.postFlightRequest if it exiests and agg is enabled'
    • 'should skip agg.postFlightRequest call if the agg is disabled'
    • tabifies response data - removed metricsAtAllLevels
  • search_source.test.ts
    • Fixed wrong nesting of isPartial and isRunning in response mock
    • Typing of aggs required adjustments
    • Use fetch$ instead of deprecated fetch
    • sets the value for the property with AggConfigs
    • fetch$
      • Removed duplicate legacy msearch tests and grouped others
      • shareReplays result
      • should emit error on empty response
      • inspector
        • calls inspector if provided
        • calls inspector only once, with multiple subs (shareReplay)
        • calls error on inspector
      • postFlightRequest
        • doesnt call any post flight requests if disabled
        • doesnt call any post flight if searchsource has error
        • calls post flight requests, fires 1 extra response, returns last response
        • calls post flight requests, handles error
  • esaggs.test.ts
    • request format change (client and server)
  • agg_configs.test.ts
    • Use hierarchical: true

Functional tests

  • Added a functional test that uses search source to send a bucket aggregation and validates the presence of the other bucket in the final response.

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@lizozom lizozom requested review from ppisljar and lukeelmers April 7, 2021 10:11
@lizozom lizozom added Team:AppServices v7.13.0 v8.0.0 auto-backport Deprecated - use backport:version if exact versions are needed release_note:skip Skip the PR/issue when compiling release notes labels Apr 7, 2021
@lizozom
Copy link
Contributor Author

lizozom commented Apr 9, 2021

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

merge conflict between base and head

if (responseAgg[aggWithOtherBucket.id]) {
return responseAgg[aggWithOtherBucket.id].buckets;
if (responseAgg?.[aggWithOtherBucket.id]) {
return (responseAgg[aggWithOtherBucket.id] as any).buckets;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Introduced response typing, but I don't want to broaden the refactoring of this code

@lizozom lizozom marked this pull request as ready for review April 13, 2021 08:10
@lizozom lizozom requested a review from a team April 13, 2021 08:10
@lizozom lizozom requested a review from a team as a code owner April 13, 2021 08:10
@lizozom lizozom requested a review from a team as a code owner April 14, 2021 10:33
@lizozom
Copy link
Contributor Author

lizozom commented Apr 14, 2021

@elasticmachine merge upstream

@ryankeairns
Copy link
Contributor

@lizozom can you add a screenshot of the resulting UI? It will help with the quick design review, thanks.

@lizozom
Copy link
Contributor Author

lizozom commented Apr 14, 2021

@ryankeairns I don't think this deserves a review honestly.
It's just a demo plugin we use for automated testing, but I was bothered by the text padding 😅

@lizozom
Copy link
Contributor Author

lizozom commented Apr 16, 2021

@elasticmachine merge upstream

@lizozom lizozom merged commit 1a3e033 into elastic:master Apr 18, 2021
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Apr 18, 2021
* Move inspector adapter integration into search source

* docs and ts

* Move other bucket to search source

* test ts + delete unused tabilfy function

* hierarchical param in aggconfig.
ts improvements
more inspector tests

* fix jest

* separate inspect
more tests

* jest

* inspector

* Error handling and more tests

* put the fun in functional tests

* code review

* Add functional test for other bucket in search example app

* test

* test

* ts

* test

* test

* ts

Co-authored-by: Kibana Machine <[email protected]>
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.x

This backport PR will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Apr 18, 2021
* Move inspector adapter integration into search source

* docs and ts

* Move other bucket to search source

* test ts + delete unused tabilfy function

* hierarchical param in aggconfig.
ts improvements
more inspector tests

* fix jest

* separate inspect
more tests

* jest

* inspector

* Error handling and more tests

* put the fun in functional tests

* code review

* Add functional test for other bucket in search example app

* test

* test

* ts

* test

* test

* ts

Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Liza Katz <[email protected]>
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
discover 407.5KB 407.2KB -336.0B
maps 2.6MB 2.6MB -184.0B
total -520.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
data 788.9KB 789.8KB +880.0B
Unknown metric groups

API count

id before after diff
data 3438 3440 +2

API count missing comments

id before after diff
data 2946 2945 -1

API count with any type

id before after diff
data 81 79 -2

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @lizozom

jloleysens added a commit to jloleysens/kibana that referenced this pull request Apr 19, 2021
…te-legacy-es-client

* 'master' of github.com:elastic/kibana: (102 commits)
  [Exploratory view] integerate page views to exploratory view (elastic#97258)
  Fix typo in license_api_guard README name and import http server mocks from public interface (elastic#97334)
  Avoid mutating KQL query when validating it (elastic#97081)
  Add description as title on tag badge (elastic#97109)
  Remove legacy ES client usages in `home` and `xpack_legacy` (elastic#97359)
  [Fleet] Finer-grained error information from install/upgrade API (elastic#95649)
  Rule registry bundle size (elastic#97251)
  [Partial Results] Move other bucket into Search Source (elastic#96384)
  [Dashboard] Makes lens default editor for creating new panels (elastic#96181)
  skip flaky suite (elastic#97387)
  [Asset Management] Agent picker follow up (elastic#97357)
  skip flaky suite (elastic#97382)
  [Security Solutions] Fixes flake with cypress tests (elastic#97329)
  skip flaky suite (elastic#97355)
  Skip test to try and stabilize master
  minimize number of so fild asserted in tests. it creates flakines when implementation details change (elastic#97374)
  [Search Sessions] Client side search cache (elastic#92439)
  [SavedObjects] Add aggregations support (elastic#96292)
  [Reporting] Remove legacy elasticsearch client usage from the reporting plugin (elastic#97184)
  [kbnClient] fix basePath handling and export reponse type (elastic#97277)
  ...

# Conflicts:
#	x-pack/plugins/watcher/server/lib/license_pre_routing_factory/license_pre_routing_factory.ts
#	x-pack/plugins/watcher/server/plugin.ts
#	x-pack/plugins/watcher/server/routes/api/indices/register_get_route.ts
#	x-pack/plugins/watcher/server/routes/api/license/register_refresh_route.ts
#	x-pack/plugins/watcher/server/routes/api/register_list_fields_route.ts
#	x-pack/plugins/watcher/server/routes/api/register_load_history_route.ts
#	x-pack/plugins/watcher/server/routes/api/settings/register_load_route.ts
#	x-pack/plugins/watcher/server/routes/api/watch/action/register_acknowledge_route.ts
#	x-pack/plugins/watcher/server/routes/api/watch/register_activate_route.ts
#	x-pack/plugins/watcher/server/routes/api/watch/register_deactivate_route.ts
#	x-pack/plugins/watcher/server/routes/api/watch/register_delete_route.ts
#	x-pack/plugins/watcher/server/routes/api/watch/register_execute_route.ts
#	x-pack/plugins/watcher/server/routes/api/watch/register_history_route.ts
#	x-pack/plugins/watcher/server/routes/api/watch/register_load_route.ts
#	x-pack/plugins/watcher/server/routes/api/watch/register_save_route.ts
#	x-pack/plugins/watcher/server/routes/api/watch/register_visualize_route.ts
#	x-pack/plugins/watcher/server/routes/api/watches/register_delete_route.ts
#	x-pack/plugins/watcher/server/routes/api/watches/register_list_route.ts
#	x-pack/plugins/watcher/server/shared_imports.ts
#	x-pack/plugins/watcher/server/types.ts
@timroes timroes added the Feature:Search Querying infrastructure in Kibana label Apr 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed Feature:Search Querying infrastructure in Kibana release_note:enhancement v7.13.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants