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

[Search] Server strategy example #71679

Merged
merged 38 commits into from
Aug 11, 2020

Conversation

lizozom
Copy link
Contributor

@lizozom lizozom commented Jul 14, 2020

Summary

This example shows how to use the data services, focusing on the data.search.search API.

It illustrates:

  • Selecting an IndexPattern and a Field.
  • Getting the configurations from TopNavMenu.
  • Building an aggregation using AggConfigs
  • Using the search API to execute an Elasticsearch search:
    • Using the default server side es strategy. Data will be fetched synchronously or asynchronously depending on licensing.
    • Using a custom myStrategy that takes a custom request and returns a custom response.
    • Running a search on the server using the server side service in a synchronous manner.
    • TODO: Add a server side utility for async search.

To run, start Kibana with yarn start --run-examples and find the plugin on the Developer Examples page

image

image

This PR also renames the names is_partial and is_running we get from ES to isPartial and isRunning (compatible with naming standards in Kibana.

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@lizozom lizozom self-assigned this Jul 15, 2020
@lizozom lizozom marked this pull request as ready for review July 15, 2020 12:04
@lizozom lizozom requested review from a team as code owners July 15, 2020 12:04
@lizozom lizozom requested a review from lukasolson July 15, 2020 12:04
@lizozom lizozom added v7.9.0 v8.0.0 Feature:Search Querying infrastructure in Kibana Team:AppArch labels Jul 15, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-arch (Team:AppArch)

@lizozom lizozom added the release_note:skip Skip the PR/issue when compiling release notes label Jul 15, 2020
@lizozom lizozom requested a review from alexwizp July 15, 2020 13:16
Copy link
Contributor

@mdefazio mdefazio left a comment

Choose a reason for hiding this comment

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

All this css looks good! ;)

Copy link
Member

@lukasolson lukasolson left a comment

Choose a reason for hiding this comment

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

Added a few minor comments below, overall this is looking good. I'm wondering if we may want to show a little more realistic example (rather than a strategy that just returns an extra parameter).

export const PLUGIN_ID = 'searchExamples';
export const PLUGIN_NAME = 'search_examples';

export interface IMyStrategyResponse extends IEsSearchResponse {
Copy link
Member

Choose a reason for hiding this comment

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

Just some thoughts: I wonder if it will be more common for custom strategies to extend IKibanaSearchResponse rather than IEsSearchResponse since they will likely be doing some sort of data manipulation and not sending the raw response back.

examples/search_examples/public/components/app.tsx Outdated Show resolved Hide resolved
examples/search_examples/public/components/app.tsx Outdated Show resolved Hide resolved
/**
* Indicates whether async search is still in flight
*/
isRunning?: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

It probably makes sense to either move these directly to IKibanaSearchResponse, or move id inside here. Maybe we can have a conversation about what should be in IKibanaSearchResponse (or if it's necessary).

@lizozom lizozom requested a review from a team July 20, 2020 10:06
@lizozom lizozom requested a review from a team as a code owner July 22, 2020 16:00
@lizozom lizozom changed the title Search server strategy example [Search] server strategy example Jul 23, 2020
@lizozom lizozom marked this pull request as draft July 27, 2020 13:55
Copy link
Member

@lukasolson lukasolson left a comment

Choose a reason for hiding this comment

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

Added a couple of minor things below... I think this example illustrates that our types need a little work. I have a simple idea I can run by you tomorrow about improving it.

Comment on lines +128 to +129
const aggs = [{ type: 'avg', params: { field: selectedField.name } }];
const aggsDsl = data.search.aggs.createAggConfigs(indexPattern, aggs).toDsl();
Copy link
Member

Choose a reason for hiding this comment

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

I think it's good that we're using the agg configs service here, but it doesn't answer the question, "Why would I want to use the data.search.aggs service instead of just writing the DSL myself?" Maybe just adding a comment would be sufficient.

examples/search_examples/public/application.tsx Outdated Show resolved Hide resolved
examples/search_examples/public/application.tsx Outdated Show resolved Hide resolved
examples/search_examples/public/components/app.tsx Outdated Show resolved Hide resolved
examples/search_examples/public/components/app.tsx Outdated Show resolved Hide resolved
examples/search_examples/public/components/app.tsx Outdated Show resolved Hide resolved
@lizozom
Copy link
Contributor Author

lizozom commented Aug 6, 2020

@elasticmachine merge upstream

@lizozom
Copy link
Contributor Author

lizozom commented Aug 6, 2020

@elasticmachine merge upstream

@lizozom lizozom requested a review from lukasolson August 10, 2020 12:22
@lizozom
Copy link
Contributor Author

lizozom commented Aug 11, 2020

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

page load bundle size

id value diff baseline
data 1.4MB +1.7KB 1.4MB
dataEnhanced 178.0KB +111.0B 177.9KB
total +1.8KB

History

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

Copy link
Member

@lukasolson lukasolson left a comment

Choose a reason for hiding this comment

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

LGTM

@lizozom lizozom merged commit 506e953 into elastic:master Aug 11, 2020
lizozom added a commit to lizozom/kibana that referenced this pull request Aug 11, 2020
* Server strategy example

* Add tsconfig
Renamed is_partial to isPartial
Added isPartial and isRunning to OSS response type

* Docs + remove unused sample code

* Fix test naming of arguments

* ts

* ts fix

* Add filters and query input selector

* Update examples/search_examples/public/components/app.tsx

Co-authored-by: Lukas Olson <[email protected]>

* Use new service

* exapmle plugin ts

* unsubscribe + use timefilter

* typo

* docs

* Add comments and use agg config

* Added agg configs
Added field selector
Added a custom input param

* Adding getEsQuery to query service (??)

* Add server side example

* docs

* caps

* list plugin in examples page

* fix typo

* Update examples/search_examples/public/application.tsx

Co-authored-by: Lukas Olson <[email protected]>

* Update examples/search_examples/public/application.tsx

Co-authored-by: Lukas Olson <[email protected]>

* Update examples/search_examples/public/components/app.tsx

Co-authored-by: Lukas Olson <[email protected]>

* Update examples/search_examples/public/components/app.tsx

Co-authored-by: Lukas Olson <[email protected]>

* Update examples/search_examples/public/components/app.tsx

Co-authored-by: Lukas Olson <[email protected]>

* eslint

Co-authored-by: Lukas Olson <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
jloleysens added a commit to jloleysens/kibana that referenced this pull request Aug 12, 2020
…nes/processor-forms-a-d

* 'master' of github.com:elastic/kibana: (25 commits)
  [ML] Removing full lodash library imports (elastic#74742)
  [Search] Server strategy example (elastic#71679)
  [Reporting] Fix and test for Listing of Reports (elastic#74453)
  [maps] fix drawing shapes (elastic#74689)
  [Resolver] Improve simulator. Add more click-through tests and panel tests. (elastic#74601)
  Deprecate schema-less specs in Vega (elastic#73805)
  [Security Solution] Rename Administration > Hosts subtab to Endpoints (elastic#74287)
  Timelion deprecation doc (elastic#74508)
  [Functional Tests] Adds a wait time between setting the index pattern and the time field on TSVB (elastic#74736)
  [Lens] Add styling options for x and y axes on the settings popover (elastic#71829)
  [Maps] add initial location option that fits to data bounds (elastic#74583)
  theme function (elastic#73451)
  [data.ui.query] Write filters to query log from default editor. (elastic#74474)
  [data.search.SearchSource] Move some SearchSource dependencies to the server. (elastic#74607)
  [Canvas][tech-debt] Convert renderers (elastic#74134)
  [security solutions][lists] Adds end to end tests (elastic#74473)
  pluralized for occurrences vs occurrence (elastic#74564)
  Update links that pointed to CONTRIBUTING.md (elastic#74757)
  [Ingest pipelines] Implement tabs in processor flyout (elastic#74469)
  [Event log] Use Alerts client & Actions client when fetching these types of SOs (elastic#73257)
  ...

# Conflicts:
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/field_components/text_editor.tsx
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/manage_processor_form.tsx
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/append.tsx
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/bytes.tsx
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/circle.tsx
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/common_fields/field_name_field.tsx
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/common_fields/ignore_missing_field.tsx
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/convert.tsx
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/csv.tsx
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/date.tsx
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/date_index_name.tsx
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/dissect.tsx
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/dot_expander.tsx
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/drop.tsx
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/index.ts
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/shared.ts
gmmorris added a commit to gmmorris/kibana that referenced this pull request Aug 12, 2020
* master:
  [Vega] add functional tests for Vega visualization (elastic#74097)
  [ML] Removing full lodash library imports (elastic#74742)
  [Search] Server strategy example (elastic#71679)
  [Reporting] Fix and test for Listing of Reports (elastic#74453)
  [maps] fix drawing shapes (elastic#74689)
  [Resolver] Improve simulator. Add more click-through tests and panel tests. (elastic#74601)
  Deprecate schema-less specs in Vega (elastic#73805)
  [Security Solution] Rename Administration > Hosts subtab to Endpoints (elastic#74287)
  Timelion deprecation doc (elastic#74508)
lizozom added a commit that referenced this pull request Aug 12, 2020
* [Search] Server strategy example (#71679)

* Server strategy example

* Add tsconfig
Renamed is_partial to isPartial
Added isPartial and isRunning to OSS response type

* Docs + remove unused sample code

* Fix test naming of arguments

* ts

* ts fix

* Add filters and query input selector

* Update examples/search_examples/public/components/app.tsx

Co-authored-by: Lukas Olson <[email protected]>

* Use new service

* exapmle plugin ts

* unsubscribe + use timefilter

* typo

* docs

* Add comments and use agg config

* Added agg configs
Added field selector
Added a custom input param

* Adding getEsQuery to query service (??)

* Add server side example

* docs

* caps

* list plugin in examples page

* fix typo

* Update examples/search_examples/public/application.tsx

Co-authored-by: Lukas Olson <[email protected]>

* Update examples/search_examples/public/application.tsx

Co-authored-by: Lukas Olson <[email protected]>

* Update examples/search_examples/public/components/app.tsx

Co-authored-by: Lukas Olson <[email protected]>

* Update examples/search_examples/public/components/app.tsx

Co-authored-by: Lukas Olson <[email protected]>

* Update examples/search_examples/public/components/app.tsx

Co-authored-by: Lukas Olson <[email protected]>

* eslint

Co-authored-by: Lukas Olson <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>

* Update kibana.json

Co-authored-by: Lukas Olson <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
@simianhacker
Copy link
Member

Did this get reverted?

@simianhacker
Copy link
Member

Nevermind... My VS Code was not updating properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Search Querying infrastructure in Kibana release_note:skip Skip the PR/issue when compiling release notes v7.9.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants