Skip to content

Commit

Permalink
[Discover-next] add query enhancements plugin as a core plugin (#7212) (
Browse files Browse the repository at this point in the history
#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>
  • Loading branch information
sejli and kavilla authored Jul 23, 2024
1 parent 293afd1 commit f08b027
Show file tree
Hide file tree
Showing 84 changed files with 4,542 additions and 8 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/7212.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- Add query enhancements plugin as a core plugin ([#7212](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7212))
191 changes: 191 additions & 0 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
* [Home](/)

- Capabilities
- [Read_only_mode](capabilities/read_only_mode.md)
- Charts
- [Current_usage](charts/current_usage.md)
- Docker dev
- [Docker dev setup manual](docker-dev/docker-dev-setup-manual.md)
- Multi datasource
- [Client_management_design](multi-datasource/client_management_design.md)
- [High_level_design](multi-datasource/high_level_design.md)
- [User_stories](multi-datasource/user_stories.md)
- [Openapi](openapi/README.md)
- Plugins
- [Data_persistence](plugins/data_persistence.md)
- Saved_objects
- [Saved_object_repository_factory_design](saved_objects/saved_object_repository_factory_design.md)
- Telemetry
- [Telemetry](telemetry/telemetry.md)
- src
- [Core](../src/core/README.md)
- dev
- [Build](../src/dev/build/README.md)
- [I18n](../src/dev/i18n/README.md)
- plugins
- [Application_config](../src/plugins/application_config/README.md)
- [Bfetch](../src/plugins/bfetch/README.md)
- [Charts](../src/plugins/charts/README.md)
- console
- public
- application
- [Hooks](../src/plugins/console/public/application/hooks/README.md)
- [Csp_handler](../src/plugins/csp_handler/README.md)
- [Dashboard](../src/plugins/dashboard/README.md)
- [Data](../src/plugins/data/README.md)
- [Data_explorer](../src/plugins/data_explorer/README.md)
- [Data_source](../src/plugins/data_source/README.md)
- [Data_source_management](../src/plugins/data_source_management/README.md)
- [Dev_tools](../src/plugins/dev_tools/README.md)
- [Discover](../src/plugins/discover/README.md)
- [Embeddable](../src/plugins/embeddable/README.md)
- [Expressions](../src/plugins/expressions/README.md)
- [Home](../src/plugins/home/README.md)
- index_pattern_management
- public
- components
- create_index_pattern_wizard
- [CREATE_INDEX_PATTERN](../src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/CREATE_INDEX_PATTERN.md)
- [Input_control_vis](../src/plugins/input_control_vis/README.md)
- [Inspector](../src/plugins/inspector/README.md)
- [Navigation](../src/plugins/navigation/README.md)
- [Opensearch_dashboards_legacy](../src/plugins/opensearch_dashboards_legacy/README.md)
- [Opensearch_dashboards_overview](../src/plugins/opensearch_dashboards_overview/README.md)
- [Opensearch_dashboards_react](../src/plugins/opensearch_dashboards_react/README.md)
- [Opensearch_dashboards_usage_collection](../src/plugins/opensearch_dashboards_usage_collection/README.md)
- [Opensearch_dashboards_utils](../src/plugins/opensearch_dashboards_utils/README.md)
- opensearch_ui_shared
- public
- forms
- [Form_wizard](../src/plugins/opensearch_ui_shared/public/forms/form_wizard/README.md)
- [Multi_content](../src/plugins/opensearch_ui_shared/public/forms/multi_content/README.md)
- [Query_enhancements](../src/plugins/query_enhancements/README.md)
- [Saved_objects](../src/plugins/saved_objects/README.md)
- [Saved_objects_management](../src/plugins/saved_objects_management/README.md)
- [Share](../src/plugins/share/README.md)
- [Telemetry](../src/plugins/telemetry/README.md)
- [Telemetry_collection_manager](../src/plugins/telemetry_collection_manager/README.md)
- [Telemetry_management_section](../src/plugins/telemetry_management_section/README.md)
- [Ui_actions](../src/plugins/ui_actions/README.md)
- [Url_forwarding](../src/plugins/url_forwarding/README.md)
- [Usage_collection](../src/plugins/usage_collection/README.md)
- [Vis_augmenter](../src/plugins/vis_augmenter/README.md)
- [Vis_builder](../src/plugins/vis_builder/README.md)
- [Vis_default_editor](../src/plugins/vis_default_editor/README.md)
- [Vis_type_markdown](../src/plugins/vis_type_markdown/README.md)
- [Vis_type_metric](../src/plugins/vis_type_metric/README.md)
- [Vis_type_table](../src/plugins/vis_type_table/README.md)
- [Vis_type_tagcloud](../src/plugins/vis_type_tagcloud/README.md)
- [Vis_type_timeline](../src/plugins/vis_type_timeline/README.md)
- [Vis_type_timeseries](../src/plugins/vis_type_timeseries/README.md)
- [Vis_type_vega](../src/plugins/vis_type_vega/README.md)
- [Vis_type_vislib](../src/plugins/vis_type_vislib/README.md)
- [Vis_type_xy](../src/plugins/vis_type_xy/README.md)
- [Visualizations](../src/plugins/visualizations/README.md)
- [Visualize](../src/plugins/visualize/README.md)
- [Workspace](../src/plugins/workspace/README.md)
- examples
- [Dashboard_embeddable_examples](../examples/dashboard_embeddable_examples/README.md)
- [Developer_examples](../examples/developer_examples/README.md)
- embeddable_examples
- public
- [Todo](../examples/embeddable_examples/public/todo/README.md)
- [Expressions_example](../examples/expressions_example/README.md)
- [Multiple_data_source_examples](../examples/multiple_data_source_examples/README.md)
- [Routing_example](../examples/routing_example/README.md)
- [Search_examples](../examples/search_examples/README.md)
- [Ui_action_examples](../examples/ui_action_examples/README.md)
- [Ui_actions_explorer](../examples/ui_actions_explorer/README.md)
- [Url_generators_examples](../examples/url_generators_examples/README.md)
- [Url_generators_explorer](../examples/url_generators_explorer/README.md)
- packages
- [Opensearch datemath](../packages/opensearch-datemath/readme.md)
- [Opensearch eslint config opensearch dashboards](../packages/opensearch-eslint-config-opensearch-dashboards/README.md)
- [Opensearch safer lodash set](../packages/opensearch-safer-lodash-set/README.md)
- [Osd ace](../packages/osd-ace/README.md)
- [Osd apm config loader](../packages/osd-apm-config-loader/README.md)
- [Osd babel preset](../packages/osd-babel-preset/README.md)
- [Osd config](../packages/osd-config/README.md)
- [Osd config schema](../packages/osd-config-schema/README.md)
- [Osd cross platform](../packages/osd-cross-platform/README.md)
- [Osd dev utils](../packages/osd-dev-utils/README.md)
- [Osd eslint import resolver opensearch dashboards](../packages/osd-eslint-import-resolver-opensearch-dashboards/README.md)
- [Osd eslint plugin eslint](../packages/osd-eslint-plugin-eslint/README.md)
- [Osd expect](../packages/osd-expect/README.md)
- [Osd i18n](../packages/osd-i18n/README.md)
- [Osd logging](../packages/osd-logging/README.md)
- [Osd monaco](../packages/osd-monaco/README.md)
- [Osd opensearch](../packages/osd-opensearch/README.md)
- [Osd optimizer](../packages/osd-optimizer/README.md)
- [Osd plugin generator](../packages/osd-plugin-generator/README.md)
- [Osd plugin helpers](../packages/osd-plugin-helpers/README.md)
- [Osd pm](../packages/osd-pm/README.md)
- [Osd spec to console](../packages/osd-spec-to-console/README.md)
- [Osd std](../packages/osd-std/README.md)
- [Osd stylelint config](../packages/osd-stylelint-config/README.md)
- [Osd stylelint plugin stylelint](../packages/osd-stylelint-plugin-stylelint/README.md)
- [Osd telemetry tools](../packages/osd-telemetry-tools/README.md)
- [Osd test](../packages/osd-test/README.md)
- [Osd test subj selector](../packages/osd-test-subj-selector/README.md)
- [Osd ui framework](../packages/osd-ui-framework/README.md)
- [Osd ui shared deps](../packages/osd-ui-shared-deps/README.md)
- [Osd utility types](../packages/osd-utility-types/README.md)
- [Osd utils](../packages/osd-utils/README.md)
- [README](../packages/README.md)
- release-notes
- [Opensearch dashboards.release notes 1.0.0 rc1](../release-notes/opensearch-dashboards.release-notes-1.0.0-rc1.md)
- [Opensearch dashboards.release notes 1.0.0](../release-notes/opensearch-dashboards.release-notes-1.0.0.md)
- [Opensearch dashboards.release notes 1.1.0](../release-notes/opensearch-dashboards.release-notes-1.1.0.md)
- [Opensearch dashboards.release notes 1.2.0](../release-notes/opensearch-dashboards.release-notes-1.2.0.md)
- [Opensearch dashboards.release notes 1.3.0](../release-notes/opensearch-dashboards.release-notes-1.3.0.md)
- [Opensearch dashboards.release notes 1.3.1](../release-notes/opensearch-dashboards.release-notes-1.3.1.md)
- [Opensearch dashboards.release notes 1.3.10](../release-notes/opensearch-dashboards.release-notes-1.3.10.md)
- [Opensearch dashboards.release notes 1.3.11](../release-notes/opensearch-dashboards.release-notes-1.3.11.md)
- [Opensearch dashboards.release notes 1.3.12](../release-notes/opensearch-dashboards.release-notes-1.3.12.md)
- [Opensearch dashboards.release notes 1.3.13](../release-notes/opensearch-dashboards.release-notes-1.3.13.md)
- [Opensearch dashboards.release notes 1.3.14](../release-notes/opensearch-dashboards.release-notes-1.3.14.md)
- [Opensearch dashboards.release notes 1.3.15](../release-notes/opensearch-dashboards.release-notes-1.3.15.md)
- [Opensearch dashboards.release notes 1.3.17](../release-notes/opensearch-dashboards.release-notes-1.3.17.md)
- [Opensearch dashboards.release notes 1.3.2](../release-notes/opensearch-dashboards.release-notes-1.3.2.md)
- [Opensearch dashboards.release notes 1.3.3](../release-notes/opensearch-dashboards.release-notes-1.3.3.md)
- [Opensearch dashboards.release notes 1.3.5](../release-notes/opensearch-dashboards.release-notes-1.3.5.md)
- [Opensearch dashboards.release notes 1.3.6](../release-notes/opensearch-dashboards.release-notes-1.3.6.md)
- [Opensearch dashboards.release notes 1.3.7](../release-notes/opensearch-dashboards.release-notes-1.3.7.md)
- [Opensearch dashboards.release notes 1.3.8](../release-notes/opensearch-dashboards.release-notes-1.3.8.md)
- [Opensearch dashboards.release notes 1.3.9](../release-notes/opensearch-dashboards.release-notes-1.3.9.md)
- [Opensearch dashboards.release notes 2.0.0 rc1](../release-notes/opensearch-dashboards.release-notes-2.0.0-rc1.md)
- [Opensearch dashboards.release notes 2.0.0](../release-notes/opensearch-dashboards.release-notes-2.0.0.md)
- [Opensearch dashboards.release notes 2.0.1](../release-notes/opensearch-dashboards.release-notes-2.0.1.md)
- [Opensearch dashboards.release notes 2.1.0](../release-notes/opensearch-dashboards.release-notes-2.1.0.md)
- [Opensearch dashboards.release notes 2.10.0](../release-notes/opensearch-dashboards.release-notes-2.10.0.md)
- [Opensearch dashboards.release notes 2.11.0](../release-notes/opensearch-dashboards.release-notes-2.11.0.md)
- [Opensearch dashboards.release notes 2.11.1](../release-notes/opensearch-dashboards.release-notes-2.11.1.md)
- [Opensearch dashboards.release notes 2.12.0](../release-notes/opensearch-dashboards.release-notes-2.12.0.md)
- [Opensearch dashboards.release notes 2.13.0](../release-notes/opensearch-dashboards.release-notes-2.13.0.md)
- [Opensearch dashboards.release notes 2.14.0](../release-notes/opensearch-dashboards.release-notes-2.14.0.md)
- [Opensearch dashboards.release notes 2.15.0](../release-notes/opensearch-dashboards.release-notes-2.15.0.md)
- [Opensearch dashboards.release notes 2.2.0](../release-notes/opensearch-dashboards.release-notes-2.2.0.md)
- [Opensearch dashboards.release notes 2.2.1](../release-notes/opensearch-dashboards.release-notes-2.2.1.md)
- [Opensearch dashboards.release notes 2.3.0](../release-notes/opensearch-dashboards.release-notes-2.3.0.md)
- [Opensearch dashboards.release notes 2.4.0](../release-notes/opensearch-dashboards.release-notes-2.4.0.md)
- [Opensearch dashboards.release notes 2.4.1](../release-notes/opensearch-dashboards.release-notes-2.4.1.md)
- [Opensearch dashboards.release notes 2.5.0](../release-notes/opensearch-dashboards.release-notes-2.5.0.md)
- [Opensearch dashboards.release notes 2.6.0](../release-notes/opensearch-dashboards.release-notes-2.6.0.md)
- [Opensearch dashboards.release notes 2.7.0](../release-notes/opensearch-dashboards.release-notes-2.7.0.md)
- [Opensearch dashboards.release notes 2.8.0](../release-notes/opensearch-dashboards.release-notes-2.8.0.md)
- [Opensearch dashboards.release notes 2.9.0](../release-notes/opensearch-dashboards.release-notes-2.9.0.md)
- scripts
- [README](../scripts/README.md)
- [DOCS_README](DOCS_README.md)
- [Theme](theme.md)
- [CHANGELOG](../CHANGELOG.md)
- [CODE_OF_CONDUCT](../CODE_OF_CONDUCT.md)
- [COMMUNICATIONS](../COMMUNICATIONS.md)
- [CONTRIBUTING](../CONTRIBUTING.md)
- [DEVELOPER_GUIDE](../DEVELOPER_GUIDE.md)
- [MAINTAINERS](../MAINTAINERS.md)
- [README](../README.md)
- [RELEASING](../RELEASING.md)
- [SECURITY](../SECURITY.md)
- [TESTING](../TESTING.md)
- [TYPESCRIPT](../TYPESCRIPT.md)
6 changes: 6 additions & 0 deletions src/plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,12 @@ export {
IndexPatternSelectProps,
QueryStringInput,
QueryStringInputProps,
QueryEditor,
QueryEditorExtensionConfig,
QueryEditorExtensions,
QueryEditorExtensionDependencies,
QueryEditorProps,
QueryEditorTopRow,
// for BWC, keeping the old name
IUiStart as DataPublicPluginStartUi,
} from './ui';
Expand Down
8 changes: 8 additions & 0 deletions src/plugins/data/public/ui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,13 @@ export {
export { IndexPatternSelectProps } from './index_pattern_select';
export { FilterLabel } from './filter_bar';
export { QueryStringInput, QueryStringInputProps } from './query_string_input';
export {
QueryEditorTopRow,
QueryEditor,
QueryEditorProps,
QueryEditorExtensions,
QueryEditorExtensionDependencies,
QueryEditorExtensionConfig,
} from './query_editor';
export { SearchBar, SearchBarProps, StatefulSearchBarProps } from './search_bar';
export { SuggestionsComponent } from './typeahead';
6 changes: 5 additions & 1 deletion src/plugins/data/public/ui/query_editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@ export const QueryEditor = (props: QueryEditorProps) => (
);
export type { QueryEditorProps };

export { QueryEditorExtensions, QueryEditorExtensionConfig } from './query_editor_extensions';
export {
QueryEditorExtensions,
QueryEditorExtensionDependencies,
QueryEditorExtensionConfig,
} from './query_editor_extensions';
23 changes: 17 additions & 6 deletions src/plugins/data/public/ui/query_editor/query_editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,10 @@ export default class QueryEditorUI extends Component<Props, State> {
: undefined;
this.onChange(newQuery, dateRange);
this.onSubmit(newQuery, dateRange);
this.setState({ isDataSourcesVisible: enhancement?.searchBar?.showDataSourceSelector ?? true });
this.setState({
isDataSourcesVisible: enhancement?.searchBar?.showDataSourcesSelector ?? true,
isDataSetsVisible: enhancement?.searchBar?.showDataSetsSelector ?? true,
});
};

private initPersistedLog = () => {
Expand All @@ -225,10 +228,15 @@ export default class QueryEditorUI extends Component<Props, State> {
private initDataSourcesVisibility = () => {
if (this.componentIsUnmounting) return;

const isDataSourcesVisible =
this.props.settings.getQueryEnhancements(this.props.query.language)?.searchBar
?.showDataSourceSelector ?? true;
this.setState({ isDataSourcesVisible });
return this.props.settings.getQueryEnhancements(this.props.query.language)?.searchBar
?.showDataSourcesSelector;
};

private initDataSetsVisibility = () => {
if (this.componentIsUnmounting) return;

return this.props.settings.getQueryEnhancements(this.props.query.language)?.searchBar
?.showDataSetsSelector;
};

public onMouseEnterSuggestion = (index: number) => {
Expand All @@ -245,7 +253,10 @@ export default class QueryEditorUI extends Component<Props, State> {

this.initPersistedLog();
// this.fetchIndexPatterns().then(this.updateSuggestions);
this.initDataSourcesVisibility();
this.setState({
isDataSourcesVisible: this.initDataSourcesVisibility() || true,
isDataSetsVisible: this.initDataSetsVisibility() || true,
});
}

public componentDidUpdate(prevProps: Props) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ export const QueryEditorExtensions = (props: ComponentProps<typeof LazyQueryEdit
</React.Suspense>
);

export { QueryEditorExtensionConfig } from './query_editor_extension';
export {
QueryEditorExtensionDependencies,
QueryEditorExtensionConfig,
} from './query_editor_extension';
7 changes: 7 additions & 0 deletions src/plugins/query_enhancements/.i18nrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"prefix": "queryEnhancements",
"paths": {
"queryEnhancements": "."
},
"translations": ["translations/ja-JP.json"]
}
9 changes: 9 additions & 0 deletions src/plugins/query_enhancements/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Query Enhancements Plugin

Optional plugin, that registers query enhancing capabilities within
the application.

## List of enhancements

* PPL within Discover
* SQL within Discover
23 changes: 23 additions & 0 deletions src/plugins/query_enhancements/common/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { schema, TypeOf } from '@osd/config-schema';

export const configSchema = schema.object({
enabled: schema.boolean({ defaultValue: true }),
queryAssist: schema.object({
supportedLanguages: schema.arrayOf(
schema.object({
language: schema.string(),
agentConfig: schema.string(),
}),
{
defaultValue: [{ language: 'PPL', agentConfig: 'os_query_assist_ppl' }],
}
),
}),
});

export type ConfigSchema = TypeOf<typeof configSchema>;
47 changes: 47 additions & 0 deletions src/plugins/query_enhancements/common/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export const PLUGIN_ID = 'queryEnhancements';
export const PLUGIN_NAME = 'queryEnhancements';

export const BASE_API = '/api/enhancements';

export const SEARCH_STRATEGY = {
PPL: 'ppl',
SQL: 'sql',
SQL_ASYNC: 'sqlasync',
};

export const API = {
SEARCH: `${BASE_API}/search`,
PPL_SEARCH: `${BASE_API}/search/${SEARCH_STRATEGY.PPL}`,
SQL_SEARCH: `${BASE_API}/search/${SEARCH_STRATEGY.SQL}`,
SQL_ASYNC_SEARCH: `${BASE_API}/search/${SEARCH_STRATEGY.SQL_ASYNC}`,
QUERY_ASSIST: {
LANGUAGES: `${BASE_API}/assist/languages`,
GENERATE: `${BASE_API}/assist/generate`,
},
DATA_SOURCE: {
CONNECTIONS: `${BASE_API}/datasource/connections`,
},
};

export const URI = {
PPL: '/_plugins/_ppl',
SQL: '/_plugins/_sql',
ASYNC_QUERY: '/_plugins/_async_query',
ML: '/_plugins/_ml',
OBSERVABILITY: '/_plugins/_observability',
DATA_CONNECTIONS: '/_plugins/_query/_datasources',
};

export const OPENSEARCH_API = {
PANELS: `${URI.OBSERVABILITY}/object`,
DATA_CONNECTIONS: URI.DATA_CONNECTIONS,
};

export const UI_SETTINGS = {};

export const ERROR_DETAILS = { GUARDRAILS_TRIGGERED: 'guardrails triggered' };
8 changes: 8 additions & 0 deletions src/plugins/query_enhancements/common/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export * from './constants';
export * from './types';
export * from './utils';
6 changes: 6 additions & 0 deletions src/plugins/query_enhancements/common/query_assist/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export { QueryAssistParameters, QueryAssistResponse } from './types';
Loading

0 comments on commit f08b027

Please sign in to comment.