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

[Discover-next] Support data sources for query assist #6972

Conversation

joshuali925
Copy link
Member

Description

  • disable query assist for non-default datasource (flint)
  • disable query assist input when loading
  • support MDS for query assist

Issues Resolved

Screenshot

Testing the changes

Changelog

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

Copy link
Contributor

github-actions bot commented Jun 7, 2024

ℹ️ Manual Changeset Creation Reminder

Please ensure manual commit for changeset file 6972.yml under folder changelogs/fragments to complete this PR.

If you want to use the available OpenSearch Changeset Bot App to avoid manual creation of changeset file you can install it in your forked repository following this link.

For more information about formatting of changeset files, please visit OpenSearch Auto Changeset and Release Notes Tool.

Copy link

codecov bot commented Jun 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (feature/discover-next@3ef7479). Learn more about missing BASE report.

Additional details and impacted files
@@                   Coverage Diff                    @@
##             feature/discover-next    #6972   +/-   ##
========================================================
  Coverage                         ?   66.94%           
========================================================
  Files                            ?     3452           
  Lines                            ?    68327           
  Branches                         ?    11160           
========================================================
  Hits                             ?    45740           
  Misses                           ?    19969           
  Partials                         ?     2618           
Flag Coverage Δ
Linux_4 34.71% <ø> (?)
Windows_1 33.01% <ø> (?)
Windows_2 54.90% <ø> (?)
Windows_3 44.68% <ø> (?)
Windows_4 34.71% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Joshua Li <joshuali925@gmail.com>
Signed-off-by: Joshua Li <joshuali925@gmail.com>
Signed-off-by: Joshua Li <joshuali925@gmail.com>
Signed-off-by: Joshua Li <joshuali925@gmail.com>
This reverts commit 983514e.
The test configs are not yet setup in query_enhancements plugins.

Signed-off-by: Joshua Li <joshuali925@gmail.com>
@kavilla kavilla merged commit 328e08e into opensearch-project:feature/discover-next Jun 7, 2024
44 of 68 checks passed
joshuali925 added a commit to joshuali925/OpenSearch-Dashboards that referenced this pull request Jun 14, 2024
…ject#6972)

* disable query assist for non-default datasource

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* disable query assist input when loading

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* support MDS for query assist

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* add unit tests for agents

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* Revert "add unit tests for agents"

This reverts commit 983514e.
The test configs are not yet setup in query_enhancements plugins.

Signed-off-by: Joshua Li <joshuali925@gmail.com>

---------

Signed-off-by: Joshua Li <joshuali925@gmail.com>
(cherry picked from commit 328e08e)
kavilla pushed a commit that referenced this pull request Jun 20, 2024
### Description

see #6894 

This PR picks #6894, #6895, #6933, #6972 to main. Additionally,
- separates extensions from query enhancements
- adds banner support
- partially revert #6972 as it's pending on the data source commit to main
- renames search bar extension to query editor extension

A query editor extension can display a UI component above the query editor and/or a banner above the language selector. The component has the ability to read and write discover search bar states to enhance the search experience for users. The configuration is part of UI Enhancements.

```ts
export interface QueryEditorExtensionDependencies {
  /**
   * Currently selected index patterns.
   */
  indexPatterns?: Array<IIndexPattern | string>;
  /**
   * Currently selected data source.
   */
  dataSource?: DataSource;
  /**
   * Currently selected query language.
   */
  language: string;
}

export interface QueryEditorExtensionConfig {
  /**
   * The id for the search bar extension.
   */
  id: string;
  /**
   * Lower order indicates higher position on UI.
   */
  order: number;
  /**
   * A function that determines if the search bar extension is enabled and should be rendered on UI.
   * @returns whether the extension is enabled.
   */
  isEnabled: (dependencies: QueryEditorExtensionDependencies) => Promise<boolean>;
  /**
   * A function that returns the search bar extension component. The component
   * will be displayed on top of the query editor in the search bar.
   * @param dependencies - The dependencies required for the extension.
   * @returns The component the search bar extension.
   */
  getComponent?: (dependencies: QueryEditorExtensionDependencies) => React.ReactElement | null;
  /**
   * A function that returns the search bar extension banner. The banner is a
   * component that will be displayed on top of the search bar.
   * @param dependencies - The dependencies required for the extension.
   * @returns The component the search bar extension.
   */
  getBanner?: (dependencies: QueryEditorExtensionDependencies) => React.ReactElement | null;
}

export interface UiEnhancements {
  query?: QueryEnhancement;
+ queryEditorExtension?: QueryEditorExtensionConfig;
}
```
Developers can utilize search bar extensions to add additional features to the search bar, such as query assist.

Issues resolved: #6077

A search bar extension can display a UI component above the query bar. The component has the ability to read and write discover search bar states to enhance the search experience for users. The configuration is part of Query Enhancements.

Signed-off-by: Joshua Li <joshuali925@gmail.com>
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jun 20, 2024
### Description

see #6894

This PR picks #6894, #6895, #6933, #6972 to main. Additionally,
- separates extensions from query enhancements
- adds banner support
- partially revert #6972 as it's pending on the data source commit to main
- renames search bar extension to query editor extension

A query editor extension can display a UI component above the query editor and/or a banner above the language selector. The component has the ability to read and write discover search bar states to enhance the search experience for users. The configuration is part of UI Enhancements.

```ts
export interface QueryEditorExtensionDependencies {
  /**
   * Currently selected index patterns.
   */
  indexPatterns?: Array<IIndexPattern | string>;
  /**
   * Currently selected data source.
   */
  dataSource?: DataSource;
  /**
   * Currently selected query language.
   */
  language: string;
}

export interface QueryEditorExtensionConfig {
  /**
   * The id for the search bar extension.
   */
  id: string;
  /**
   * Lower order indicates higher position on UI.
   */
  order: number;
  /**
   * A function that determines if the search bar extension is enabled and should be rendered on UI.
   * @returns whether the extension is enabled.
   */
  isEnabled: (dependencies: QueryEditorExtensionDependencies) => Promise<boolean>;
  /**
   * A function that returns the search bar extension component. The component
   * will be displayed on top of the query editor in the search bar.
   * @param dependencies - The dependencies required for the extension.
   * @returns The component the search bar extension.
   */
  getComponent?: (dependencies: QueryEditorExtensionDependencies) => React.ReactElement | null;
  /**
   * A function that returns the search bar extension banner. The banner is a
   * component that will be displayed on top of the search bar.
   * @param dependencies - The dependencies required for the extension.
   * @returns The component the search bar extension.
   */
  getBanner?: (dependencies: QueryEditorExtensionDependencies) => React.ReactElement | null;
}

export interface UiEnhancements {
  query?: QueryEnhancement;
+ queryEditorExtension?: QueryEditorExtensionConfig;
}
```
Developers can utilize search bar extensions to add additional features to the search bar, such as query assist.

Issues resolved: #6077

A search bar extension can display a UI component above the query bar. The component has the ability to read and write discover search bar states to enhance the search experience for users. The configuration is part of Query Enhancements.

Signed-off-by: Joshua Li <joshuali925@gmail.com>
(cherry picked from commit 4f54049)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
kavilla pushed a commit that referenced this pull request Jun 22, 2024
### Description

see #6894

This PR picks #6894, #6895, #6933, #6972 to main. Additionally,
- separates extensions from query enhancements
- adds banner support
- partially revert #6972 as it's pending on the data source commit to main
- renames search bar extension to query editor extension

A query editor extension can display a UI component above the query editor and/or a banner above the language selector. The component has the ability to read and write discover search bar states to enhance the search experience for users. The configuration is part of UI Enhancements.

```ts
export interface QueryEditorExtensionDependencies {
  /**
   * Currently selected index patterns.
   */
  indexPatterns?: Array<IIndexPattern | string>;
  /**
   * Currently selected data source.
   */
  dataSource?: DataSource;
  /**
   * Currently selected query language.
   */
  language: string;
}

export interface QueryEditorExtensionConfig {
  /**
   * The id for the search bar extension.
   */
  id: string;
  /**
   * Lower order indicates higher position on UI.
   */
  order: number;
  /**
   * A function that determines if the search bar extension is enabled and should be rendered on UI.
   * @returns whether the extension is enabled.
   */
  isEnabled: (dependencies: QueryEditorExtensionDependencies) => Promise<boolean>;
  /**
   * A function that returns the search bar extension component. The component
   * will be displayed on top of the query editor in the search bar.
   * @param dependencies - The dependencies required for the extension.
   * @returns The component the search bar extension.
   */
  getComponent?: (dependencies: QueryEditorExtensionDependencies) => React.ReactElement | null;
  /**
   * A function that returns the search bar extension banner. The banner is a
   * component that will be displayed on top of the search bar.
   * @param dependencies - The dependencies required for the extension.
   * @returns The component the search bar extension.
   */
  getBanner?: (dependencies: QueryEditorExtensionDependencies) => React.ReactElement | null;
}

export interface UiEnhancements {
  query?: QueryEnhancement;
+ queryEditorExtension?: QueryEditorExtensionConfig;
}
```
Developers can utilize search bar extensions to add additional features to the search bar, such as query assist.

Issues resolved: #6077

A search bar extension can display a UI component above the query bar. The component has the ability to read and write discover search bar states to enhance the search experience for users. The configuration is part of Query Enhancements.


(cherry picked from commit 4f54049)

Signed-off-by: Joshua Li <joshuali925@gmail.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
mengweieric pushed a commit to mengweieric/OpenSearch-Dashboards that referenced this pull request Jun 24, 2024
### Description

see opensearch-project#6894 

This PR picks opensearch-project#6894, opensearch-project#6895, opensearch-project#6933, opensearch-project#6972 to main. Additionally,
- separates extensions from query enhancements
- adds banner support
- partially revert opensearch-project#6972 as it's pending on the data source commit to main
- renames search bar extension to query editor extension

A query editor extension can display a UI component above the query editor and/or a banner above the language selector. The component has the ability to read and write discover search bar states to enhance the search experience for users. The configuration is part of UI Enhancements.

```ts
export interface QueryEditorExtensionDependencies {
  /**
   * Currently selected index patterns.
   */
  indexPatterns?: Array<IIndexPattern | string>;
  /**
   * Currently selected data source.
   */
  dataSource?: DataSource;
  /**
   * Currently selected query language.
   */
  language: string;
}

export interface QueryEditorExtensionConfig {
  /**
   * The id for the search bar extension.
   */
  id: string;
  /**
   * Lower order indicates higher position on UI.
   */
  order: number;
  /**
   * A function that determines if the search bar extension is enabled and should be rendered on UI.
   * @returns whether the extension is enabled.
   */
  isEnabled: (dependencies: QueryEditorExtensionDependencies) => Promise<boolean>;
  /**
   * A function that returns the search bar extension component. The component
   * will be displayed on top of the query editor in the search bar.
   * @param dependencies - The dependencies required for the extension.
   * @returns The component the search bar extension.
   */
  getComponent?: (dependencies: QueryEditorExtensionDependencies) => React.ReactElement | null;
  /**
   * A function that returns the search bar extension banner. The banner is a
   * component that will be displayed on top of the search bar.
   * @param dependencies - The dependencies required for the extension.
   * @returns The component the search bar extension.
   */
  getBanner?: (dependencies: QueryEditorExtensionDependencies) => React.ReactElement | null;
}

export interface UiEnhancements {
  query?: QueryEnhancement;
+ queryEditorExtension?: QueryEditorExtensionConfig;
}
```
Developers can utilize search bar extensions to add additional features to the search bar, such as query assist.

Issues resolved: opensearch-project#6077

A search bar extension can display a UI component above the query bar. The component has the ability to read and write discover search bar states to enhance the search experience for users. The configuration is part of Query Enhancements.

Signed-off-by: Joshua Li <joshuali925@gmail.com>
kavilla added a commit to kavilla/queryEnhancements that referenced this pull request Jun 25, 2024
This PR picks

[Discover-next] add query assist to query enhancements plugin opensearch-project/OpenSearch-Dashboards#6895
[Discover-next] Address comments for search bar extensions and query assist opensearch-project/OpenSearch-Dashboards#6933
[Discover-next] Support data sources for query assist opensearch-project/OpenSearch-Dashboards#6972
adds query assist banner

    a callout that advertises query assist when user has at least 1 language with query assist configured and is not on a configured language

adds index selector for local cluster only

    This is a temporary solution given that in discover the index pattern
    selector will be removed. Before datasource and dataset selectors are
    added, query assist will rely on this index pattern selector to
    determine which index user wants to query.

Signed-off-by: Joshua Li <joshuali925@gmail.com>
kavilla pushed a commit to kavilla/OpenSearch-Dashboards-1 that referenced this pull request Jul 9, 2024
…ject#6972)

* disable query assist for non-default datasource

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* disable query assist input when loading

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* support MDS for query assist

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* add unit tests for agents

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* Revert "add unit tests for agents"

This reverts commit 983514e.
The test configs are not yet setup in query_enhancements plugins.

Signed-off-by: Joshua Li <joshuali925@gmail.com>

---------

Signed-off-by: Joshua Li <joshuali925@gmail.com>
(cherry picked from commit 328e08e)
kavilla added a commit that referenced this pull request Jul 16, 2024
### Description

Introduces the addition of a new core plugin called `Query Enhancements`

This plugin seems to be focused on enhancing query capabilities, particularly in areas like PPL (Piped Processing Language), SQL, and natural language query assistance.

#### Plugin Configuration and Setup

The plugin is set up with the necessary configuration files:

- src/plugins/query_enhancements/opensearch_dashboards.json: Defines the plugin's metadata and dependencies.
- src/plugins/query_enhancements/common/config.ts: Contains the configuration schema for the plugin.
- src/plugins/query_enhancements/public/plugin.tsx: The main plugin file that sets up the public-facing part of the plugin.
- src/plugins/query_enhancements/server/plugin.ts: The server-side setup for the plugin.

#### Query Assist Feature

A significant part of the plugin is dedicated to a "Query Assist" feature:

- src/plugins/query_enhancements/public/query_assist/: This directory contains components, hooks, and utilities for the Query Assist feature.
- src/plugins/query_enhancements/public/query_assist/components/query_assist_bar.tsx: A React component for the Query Assist bar.
- src/plugins/query_enhancements/server/routes/query_assist/: Server-side routing for Query Assist functionality.

#### Search Interceptors

The plugin introduces several search interceptors:

- src/plugins/query_enhancements/public/search/ppl_search_interceptor.ts
- src/plugins/query_enhancements/public/search/sql_search_interceptor.ts
- src/plugins/query_enhancements/public/search/sql_async_search_interceptor.ts

These interceptors likely modify or enhance the search functionality for different query languages.

#### Data Source Connection

There's a new feature for data source connections:

- src/plugins/query_enhancements/public/data_source_connection/: This directory contains components and services for managing data source connections.

#### Server-side Search Strategies

The plugin implements server-side search strategies for different query types:

- src/plugins/query_enhancements/server/search/ppl_search_strategy.ts
- src/plugins/query_enhancements/server/search/sql_search_strategy.ts
- src/plugins/query_enhancements/server/search/sql_async_search_strategy.ts

#### Modifications to Existing Files

There are some modifications to existing files outside the new plugin directory:

- src/plugins/data/public/index.ts: Exports new types and interfaces.
- src/plugins/data/public/ui/index.ts: Exports new UI components.
- src/plugins/data/public/ui/query_editor/index.tsx: Modifies the QueryEditor component.

#### Testing

The plugin includes a comprehensive test setup:

- src/plugins/query_enhancements/test/: Contains Jest configuration and setup files for testing.

#### Acknowledgements

Contains work by @sejli @joshuali925 @Swiddis @paulstn @mengweieric 
Thx @ashwin-pc for the description summary

### Issues Related

#6072
#6074
#6075

Commits include:
* init

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* fixing bugs and removing target

Signed-off-by: Sean Li <lnse@amazon.com>

* add target and build to .gitignore

Signed-off-by: Sean Li <lnse@amazon.com>

* Remove SQL Async and Query Assist

Going for the light weight solution for 2.15. So took out what wasn't
required deliverable.

However, I created a branch `feature/discover-next` which has the state
where all the features where added so we can port it over post 2.15.

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* adding fix for PPL queries

Signed-off-by: Sean Li <lnse@amazon.com>

* Clean up files and add helper functions

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* final touches

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* [Discover-next] add query assist to query enhancements plugin (#6895)

it adds query assist specific logic in query enhancements plugin to show a UI above the PPL search bar if user has configured PPL agent.

Issues Resolved: #6820

* add query assist to query enhancements

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* align language to uppercase

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* pick PR 6167

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* use useState hooks for query assist

There is a bug in data explorer `AppContainer` where memorized
`DiscoverCanvas` gets unmounted after `setQuery`. PR 6167 works around
it by memorizing `AppContainer`. As query assist is no longer being
unmounted, we can use proper hooks to persist state now.

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* Revert "pick PR 6167"

This reverts commit acb0d41.

Wait for official 6167 to merge to avoid conflict

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* address comments for PR 6894

Signed-off-by: Joshua Li <joshuali925@gmail.com>

---------

Signed-off-by: Joshua Li <joshuali925@gmail.com>
(cherry picked from commit 016e0f2)

* [Discover-next] Address comments for search bar extensions and query assist (#6933)

* pass dependencies to isEnabled func

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* add lazy and memo to search bar extensions

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* move ppl specific string out from query assist

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* prevent setstate after hook unmounts

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* add max-height to search bar extensions

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* prevent setstate after component unmounts

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* move ml-commons API to common/index.ts

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* improve i18n and accessibility usages

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* add hard-coded suggestions for sample data indices

Signed-off-by: Joshua Li <joshuali925@gmail.com>

---------

Signed-off-by: Joshua Li <joshuali925@gmail.com>
(cherry picked from commit 4aade0f)

* [Discover-next] Support data sources for query assist (#6972)

* disable query assist for non-default datasource

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* disable query assist input when loading

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* support MDS for query assist

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* add unit tests for agents

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* Revert "add unit tests for agents"

This reverts commit 983514e.
The test configs are not yet setup in query_enhancements plugins.

Signed-off-by: Joshua Li <joshuali925@gmail.com>

---------

Signed-off-by: Joshua Li <joshuali925@gmail.com>
(cherry picked from commit 328e08e)

* add query assist banner

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* implement banner rendering logic

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* pick opensearch-project/dashboards-observability/pull/1896

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* Conditionally render the data source select config

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* restore no space

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* add basic tests

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* add index selector

This is a temporary solution given that in discover the index pattern
selector will be removed. Before datasource and dataset selectors are
added, query assist will rely on this index pattern selector to
determine which index user wants to query.

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* MDS working with PPL and SQL

Utilizing the work from MDS to make PPL and SQL calls to a remote
cluster.

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* rename logo to mark

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* extract supported languages to config

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* Add missing license headers

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* initial implementation for async queries

Signed-off-by: Sean Li <lnse@amazon.com>

* remove queryId and sessionId from facet

Signed-off-by: Sean Li <lnse@amazon.com>

* fix: Update call out tests with intl wrapper

Signed-off-by: Simeon Widdis <sawiddis@amazon.com>

* maintenance: Add and apply lint command

Signed-off-by: Simeon Widdis <sawiddis@amazon.com>

* changing to observables

Signed-off-by: Sean Li <lnse@amazon.com>

* search interceptor and cleanup

Signed-off-by: Sean Li <lnse@amazon.com>

* moving polling class into plugin

Signed-off-by: Sean Li <lnse@amazon.com>

* Some minor clean ups plus lint

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* test: Add mock-heavy tests for sql search strategy

Signed-off-by: Simeon Widdis <sawiddis@amazon.com>

* test: add GH workflows

Signed-off-by: Simeon Widdis <sawiddis@amazon.com>

* More clean ups

Add some props interfaces and consolidated some of the facets

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* chore: apply auto-lints to plugin

Signed-off-by: Simeon Widdis <sawiddis@amazon.com>

* Not done

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* working

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* working and styled

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* add connection service

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* Update public/types.ts

Co-authored-by: Joshua Li <joshuali925@gmail.com>

* Update public/plugin.tsx

Co-authored-by: Joshua Li <joshuali925@gmail.com>

* Update public/plugin.tsx

Co-authored-by: Joshua Li <joshuali925@gmail.com>

* fix linter

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* add more tests for query assist (#31)

add more tests for query assist
update eslint config to make it work
increase index selector width

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* fix!: remove dataSource key in get connection response

The `Connection` type does not have the extra `dataSource` object around
response, and most of the time code references connection over
dataSource. remove the redundent object to make response consistent with
type.

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* change isEnabled to an observable based on selected connection

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* protect duplicated calls

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* [build] import via start services

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* Changeset file for PR #7212 created/updated

* foobar

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* updating imports still in progress

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* Update more imports

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* fix setting of state

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* fixes bugs

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* Update test

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

---------

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>
Signed-off-by: Sean Li <lnse@amazon.com>
Signed-off-by: Joshua Li <joshuali925@gmail.com>
Signed-off-by: Simeon Widdis <sawiddis@amazon.com>
Co-authored-by: Sean Li <lnse@amazon.com>
Co-authored-by: Joshua Li <joshuali925@gmail.com>
Co-authored-by: Simeon Widdis <sawiddis@amazon.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>
sejli pushed a commit to sejli/OpenSearch-Dashboards that referenced this pull request Jul 23, 2024
…earch-project#7212)

Introduces the addition of a new core plugin called `Query Enhancements`

This plugin seems to be focused on enhancing query capabilities, particularly in areas like PPL (Piped Processing Language), SQL, and natural language query assistance.

The plugin is set up with the necessary configuration files:

- src/plugins/query_enhancements/opensearch_dashboards.json: Defines the plugin's metadata and dependencies.
- src/plugins/query_enhancements/common/config.ts: Contains the configuration schema for the plugin.
- src/plugins/query_enhancements/public/plugin.tsx: The main plugin file that sets up the public-facing part of the plugin.
- src/plugins/query_enhancements/server/plugin.ts: The server-side setup for the plugin.

A significant part of the plugin is dedicated to a "Query Assist" feature:

- src/plugins/query_enhancements/public/query_assist/: This directory contains components, hooks, and utilities for the Query Assist feature.
- src/plugins/query_enhancements/public/query_assist/components/query_assist_bar.tsx: A React component for the Query Assist bar.
- src/plugins/query_enhancements/server/routes/query_assist/: Server-side routing for Query Assist functionality.

The plugin introduces several search interceptors:

- src/plugins/query_enhancements/public/search/ppl_search_interceptor.ts
- src/plugins/query_enhancements/public/search/sql_search_interceptor.ts
- src/plugins/query_enhancements/public/search/sql_async_search_interceptor.ts

These interceptors likely modify or enhance the search functionality for different query languages.

There's a new feature for data source connections:

- src/plugins/query_enhancements/public/data_source_connection/: This directory contains components and services for managing data source connections.

The plugin implements server-side search strategies for different query types:

- src/plugins/query_enhancements/server/search/ppl_search_strategy.ts
- src/plugins/query_enhancements/server/search/sql_search_strategy.ts
- src/plugins/query_enhancements/server/search/sql_async_search_strategy.ts

There are some modifications to existing files outside the new plugin directory:

- src/plugins/data/public/index.ts: Exports new types and interfaces.
- src/plugins/data/public/ui/index.ts: Exports new UI components.
- src/plugins/data/public/ui/query_editor/index.tsx: Modifies the QueryEditor component.

The plugin includes a comprehensive test setup:

- src/plugins/query_enhancements/test/: Contains Jest configuration and setup files for testing.

Contains work by @sejli @joshuali925 @Swiddis @paulstn @mengweieric
Thx @ashwin-pc for the description summary

opensearch-project#6072
opensearch-project#6074
opensearch-project#6075

Commits include:
* init

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* fixing bugs and removing target

Signed-off-by: Sean Li <lnse@amazon.com>

* add target and build to .gitignore

Signed-off-by: Sean Li <lnse@amazon.com>

* Remove SQL Async and Query Assist

Going for the light weight solution for 2.15. So took out what wasn't
required deliverable.

However, I created a branch `feature/discover-next` which has the state
where all the features where added so we can port it over post 2.15.

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* adding fix for PPL queries

Signed-off-by: Sean Li <lnse@amazon.com>

* Clean up files and add helper functions

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* final touches

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* [Discover-next] add query assist to query enhancements plugin (opensearch-project#6895)

it adds query assist specific logic in query enhancements plugin to show a UI above the PPL search bar if user has configured PPL agent.

Issues Resolved: opensearch-project#6820

* add query assist to query enhancements

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* align language to uppercase

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* pick PR 6167

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* use useState hooks for query assist

There is a bug in data explorer `AppContainer` where memorized
`DiscoverCanvas` gets unmounted after `setQuery`. PR 6167 works around
it by memorizing `AppContainer`. As query assist is no longer being
unmounted, we can use proper hooks to persist state now.

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* Revert "pick PR 6167"

This reverts commit acb0d41.

Wait for official 6167 to merge to avoid conflict

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* address comments for PR 6894

Signed-off-by: Joshua Li <joshuali925@gmail.com>

---------

Signed-off-by: Joshua Li <joshuali925@gmail.com>
(cherry picked from commit 016e0f2)

* [Discover-next] Address comments for search bar extensions and query assist (opensearch-project#6933)

* pass dependencies to isEnabled func

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* add lazy and memo to search bar extensions

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* move ppl specific string out from query assist

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* prevent setstate after hook unmounts

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* add max-height to search bar extensions

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* prevent setstate after component unmounts

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* move ml-commons API to common/index.ts

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* improve i18n and accessibility usages

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* add hard-coded suggestions for sample data indices

Signed-off-by: Joshua Li <joshuali925@gmail.com>

---------

Signed-off-by: Joshua Li <joshuali925@gmail.com>
(cherry picked from commit 4aade0f)

* [Discover-next] Support data sources for query assist (opensearch-project#6972)

* disable query assist for non-default datasource

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* disable query assist input when loading

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* support MDS for query assist

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* add unit tests for agents

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* Revert "add unit tests for agents"

This reverts commit 983514e.
The test configs are not yet setup in query_enhancements plugins.

Signed-off-by: Joshua Li <joshuali925@gmail.com>

---------

Signed-off-by: Joshua Li <joshuali925@gmail.com>
(cherry picked from commit 328e08e)

* add query assist banner

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* implement banner rendering logic

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* pick opensearch-project/dashboards-observability/pull/1896

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* Conditionally render the data source select config

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* restore no space

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* add basic tests

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* add index selector

This is a temporary solution given that in discover the index pattern
selector will be removed. Before datasource and dataset selectors are
added, query assist will rely on this index pattern selector to
determine which index user wants to query.

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* MDS working with PPL and SQL

Utilizing the work from MDS to make PPL and SQL calls to a remote
cluster.

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* rename logo to mark

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* extract supported languages to config

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* Add missing license headers

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* initial implementation for async queries

Signed-off-by: Sean Li <lnse@amazon.com>

* remove queryId and sessionId from facet

Signed-off-by: Sean Li <lnse@amazon.com>

* fix: Update call out tests with intl wrapper

Signed-off-by: Simeon Widdis <sawiddis@amazon.com>

* maintenance: Add and apply lint command

Signed-off-by: Simeon Widdis <sawiddis@amazon.com>

* changing to observables

Signed-off-by: Sean Li <lnse@amazon.com>

* search interceptor and cleanup

Signed-off-by: Sean Li <lnse@amazon.com>

* moving polling class into plugin

Signed-off-by: Sean Li <lnse@amazon.com>

* Some minor clean ups plus lint

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* test: Add mock-heavy tests for sql search strategy

Signed-off-by: Simeon Widdis <sawiddis@amazon.com>

* test: add GH workflows

Signed-off-by: Simeon Widdis <sawiddis@amazon.com>

* More clean ups

Add some props interfaces and consolidated some of the facets

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* chore: apply auto-lints to plugin

Signed-off-by: Simeon Widdis <sawiddis@amazon.com>

* Not done

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* working

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* working and styled

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* add connection service

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* Update public/types.ts

Co-authored-by: Joshua Li <joshuali925@gmail.com>

* Update public/plugin.tsx

Co-authored-by: Joshua Li <joshuali925@gmail.com>

* Update public/plugin.tsx

Co-authored-by: Joshua Li <joshuali925@gmail.com>

* fix linter

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* add more tests for query assist (opensearch-project#31)

add more tests for query assist
update eslint config to make it work
increase index selector width

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* fix!: remove dataSource key in get connection response

The `Connection` type does not have the extra `dataSource` object around
response, and most of the time code references connection over
dataSource. remove the redundent object to make response consistent with
type.

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* change isEnabled to an observable based on selected connection

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* protect duplicated calls

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* [build] import via start services

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* Changeset file for PR opensearch-project#7212 created/updated

* foobar

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* updating imports still in progress

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* Update more imports

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* fix setting of state

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* fixes bugs

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* Update test

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

---------

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>
Signed-off-by: Sean Li <lnse@amazon.com>
Signed-off-by: Joshua Li <joshuali925@gmail.com>
Signed-off-by: Simeon Widdis <sawiddis@amazon.com>
Co-authored-by: Sean Li <lnse@amazon.com>
Co-authored-by: Joshua Li <joshuali925@gmail.com>
Co-authored-by: Simeon Widdis <sawiddis@amazon.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>
(cherry picked from commit 9194d83)
Signed-off-by: Sean Li <lnse@amazon.com>
ruanyl pushed a commit that referenced this pull request Jul 23, 2024
#7400)

Introduces the addition of a new core plugin called `Query Enhancements`

This plugin seems to be focused on enhancing query capabilities, particularly in areas like PPL (Piped Processing Language), SQL, and natural language query assistance.

The plugin is set up with the necessary configuration files:

- src/plugins/query_enhancements/opensearch_dashboards.json: Defines the plugin's metadata and dependencies.
- src/plugins/query_enhancements/common/config.ts: Contains the configuration schema for the plugin.
- src/plugins/query_enhancements/public/plugin.tsx: The main plugin file that sets up the public-facing part of the plugin.
- src/plugins/query_enhancements/server/plugin.ts: The server-side setup for the plugin.

A significant part of the plugin is dedicated to a "Query Assist" feature:

- src/plugins/query_enhancements/public/query_assist/: This directory contains components, hooks, and utilities for the Query Assist feature.
- src/plugins/query_enhancements/public/query_assist/components/query_assist_bar.tsx: A React component for the Query Assist bar.
- src/plugins/query_enhancements/server/routes/query_assist/: Server-side routing for Query Assist functionality.

The plugin introduces several search interceptors:

- src/plugins/query_enhancements/public/search/ppl_search_interceptor.ts
- src/plugins/query_enhancements/public/search/sql_search_interceptor.ts
- src/plugins/query_enhancements/public/search/sql_async_search_interceptor.ts

These interceptors likely modify or enhance the search functionality for different query languages.

There's a new feature for data source connections:

- src/plugins/query_enhancements/public/data_source_connection/: This directory contains components and services for managing data source connections.

The plugin implements server-side search strategies for different query types:

- src/plugins/query_enhancements/server/search/ppl_search_strategy.ts
- src/plugins/query_enhancements/server/search/sql_search_strategy.ts
- src/plugins/query_enhancements/server/search/sql_async_search_strategy.ts

There are some modifications to existing files outside the new plugin directory:

- src/plugins/data/public/index.ts: Exports new types and interfaces.
- src/plugins/data/public/ui/index.ts: Exports new UI components.
- src/plugins/data/public/ui/query_editor/index.tsx: Modifies the QueryEditor component.

The plugin includes a comprehensive test setup:

- src/plugins/query_enhancements/test/: Contains Jest configuration and setup files for testing.

Contains work by @sejli @joshuali925 @Swiddis @paulstn @mengweieric
Thx @ashwin-pc for the description summary

#6072
#6074
#6075

Commits include:
* init



* fixing bugs and removing target



* add target and build to .gitignore



* Remove SQL Async and Query Assist

Going for the light weight solution for 2.15. So took out what wasn't
required deliverable.

However, I created a branch `feature/discover-next` which has the state
where all the features where added so we can port it over post 2.15.



* adding fix for PPL queries



* Clean up files and add helper functions



* final touches



* [Discover-next] add query assist to query enhancements plugin (#6895)

it adds query assist specific logic in query enhancements plugin to show a UI above the PPL search bar if user has configured PPL agent.

Issues Resolved: #6820

* add query assist to query enhancements



* align language to uppercase



* pick PR 6167



* use useState hooks for query assist

There is a bug in data explorer `AppContainer` where memorized
`DiscoverCanvas` gets unmounted after `setQuery`. PR 6167 works around
it by memorizing `AppContainer`. As query assist is no longer being
unmounted, we can use proper hooks to persist state now.



* Revert "pick PR 6167"

This reverts commit acb0d41.

Wait for official 6167 to merge to avoid conflict



* address comments for PR 6894



---------


(cherry picked from commit 016e0f2)

* [Discover-next] Address comments for search bar extensions and query assist (#6933)

* pass dependencies to isEnabled func



* add lazy and memo to search bar extensions



* move ppl specific string out from query assist



* prevent setstate after hook unmounts



* add max-height to search bar extensions



* prevent setstate after component unmounts



* move ml-commons API to common/index.ts



* improve i18n and accessibility usages



* add hard-coded suggestions for sample data indices



---------


(cherry picked from commit 4aade0f)

* [Discover-next] Support data sources for query assist (#6972)

* disable query assist for non-default datasource



* disable query assist input when loading



* support MDS for query assist



* add unit tests for agents



* Revert "add unit tests for agents"

This reverts commit 983514e.
The test configs are not yet setup in query_enhancements plugins.



---------


(cherry picked from commit 328e08e)

* add query assist banner



* implement banner rendering logic



* pick opensearch-project/dashboards-observability/pull/1896



* Conditionally render the data source select config



* restore no space



* add basic tests



* add index selector

This is a temporary solution given that in discover the index pattern
selector will be removed. Before datasource and dataset selectors are
added, query assist will rely on this index pattern selector to
determine which index user wants to query.



* MDS working with PPL and SQL

Utilizing the work from MDS to make PPL and SQL calls to a remote
cluster.



* rename logo to mark



* extract supported languages to config



* Add missing license headers



* initial implementation for async queries



* remove queryId and sessionId from facet



* fix: Update call out tests with intl wrapper



* maintenance: Add and apply lint command



* changing to observables



* search interceptor and cleanup



* moving polling class into plugin



* Some minor clean ups plus lint



* test: Add mock-heavy tests for sql search strategy



* test: add GH workflows



* More clean ups

Add some props interfaces and consolidated some of the facets



* chore: apply auto-lints to plugin



* Not done



* working



* working and styled



* add connection service



* Update public/types.ts



* Update public/plugin.tsx



* Update public/plugin.tsx



* fix linter



* add more tests for query assist (#31)

add more tests for query assist
update eslint config to make it work
increase index selector width



* fix!: remove dataSource key in get connection response

The `Connection` type does not have the extra `dataSource` object around
response, and most of the time code references connection over
dataSource. remove the redundent object to make response consistent with
type.



* change isEnabled to an observable based on selected connection



* protect duplicated calls



* [build] import via start services



* Changeset file for PR #7212 created/updated

* foobar



* updating imports still in progress



* Update more imports



* fix setting of state



* fixes bugs



* Update test



---------











(cherry picked from commit 9194d83)

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>
Signed-off-by: Sean Li <lnse@amazon.com>
Co-authored-by: Kawika Avilla <kavilla414@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants