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] add query enhancements plugin as a core plugin #7212

Merged
merged 75 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from 74 commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
40d6ed1
init
kavilla Jun 11, 2024
b7063c5
fixing bugs and removing target
sejli Jun 11, 2024
a34f895
Updating plugin.ts and removing target directory
kavilla Jun 11, 2024
c767590
add target and build to .gitignore
sejli Jun 11, 2024
50ce9c6
Add target and build to .gitignore
kavilla Jun 11, 2024
0783ea3
Remove SQL Async and Query Assist
kavilla Jun 12, 2024
c0304d1
adding fix for PPL queries
sejli Jun 13, 2024
c617aa5
Merge pull request #3 from sejli/ppl-fix
kavilla Jun 13, 2024
67e6b30
Clean up files and add helper functions
kavilla Jun 14, 2024
e11a384
final touches
kavilla Jun 14, 2024
8867564
Clean up files and use helper functions
kavilla Jun 14, 2024
b6d54a5
[Discover-next] add query assist to query enhancements plugin (#6895)
joshuali925 Jun 4, 2024
b0053b9
[Discover-next] Address comments for search bar extensions and query …
joshuali925 Jun 6, 2024
eb0e6f3
[Discover-next] Support data sources for query assist (#6972)
joshuali925 Jun 7, 2024
56ab13b
add query assist banner
joshuali925 Jun 17, 2024
43d1d43
implement banner rendering logic
joshuali925 Jun 18, 2024
c97cd2d
pick opensearch-project/dashboards-observability/pull/1896
joshuali925 Jun 18, 2024
48f9c7a
Conditionally render the data source select config
kavilla Jun 19, 2024
ec37345
restore no space
kavilla Jun 19, 2024
780fbd5
add basic tests
joshuali925 Jun 20, 2024
9b811a5
add index selector
joshuali925 Jun 21, 2024
c636dee
Conditionally render the data source select config
kavilla Jun 22, 2024
8572c23
MDS working with PPL and SQL
kavilla Jun 24, 2024
fd651e7
rename logo to mark
joshuali925 Jun 25, 2024
8ad8600
extract supported languages to config
joshuali925 Jun 25, 2024
90ab0bf
Add query assist to query enhancements plugin
kavilla Jun 25, 2024
97b57ba
Merge branch 'main' into kavilla/mds_working
kavilla Jun 25, 2024
3d2e294
MDS working + more cleanups
kavilla Jun 26, 2024
2e3304e
Add missing license headers
kavilla Jun 26, 2024
6192877
Adds license headers
kavilla Jun 26, 2024
0b3cb2a
initial implementation for async queries
sejli Jun 23, 2024
5a7cb21
remove queryId and sessionId from facet
sejli Jun 24, 2024
36f6218
fix: Update call out tests with intl wrapper
Swiddis Jun 27, 2024
0c84b4c
maintenance: Add and apply lint command
Swiddis Jun 27, 2024
35102fc
changing to observables
sejli Jun 27, 2024
25526d2
search interceptor and cleanup
sejli Jun 28, 2024
49cfd34
moving polling class into plugin
sejli Jun 28, 2024
f16fb12
maintenance: Add and apply lint command
kavilla Jun 28, 2024
9daa636
SQL Async queries
kavilla Jun 28, 2024
045af8e
Some minor clean ups plus lint
kavilla Jun 28, 2024
d0541ff
Merge pull request #23 from kavilla/asynccleanup
kavilla Jun 28, 2024
2ac79c5
test: Add mock-heavy tests for sql search strategy
Swiddis Jun 28, 2024
51cb500
test: add GH workflows
Swiddis Jun 28, 2024
27bf623
More clean ups
kavilla Jun 29, 2024
5b401be
Add some props interfaces and consolidated some of the facets
kavilla Jun 29, 2024
ca89c60
test: add GH workflows
kavilla Jun 29, 2024
4f52c32
fix: Update call out tests with intl wrapper
kavilla Jun 29, 2024
9e4c83c
Merge remote-tracking branch 'kavilla/main' into test/sql_search_stra…
Swiddis Jul 1, 2024
f3320a5
chore: apply auto-lints to plugin
Swiddis Jul 1, 2024
bea27f8
Not done
kavilla Jul 1, 2024
cfc4741
working
kavilla Jul 2, 2024
6d0730f
working and styled
kavilla Jul 2, 2024
388ea43
add connection service
kavilla Jul 2, 2024
48d9c00
Update public/types.ts
kavilla Jul 2, 2024
e73982b
Update public/plugin.tsx
kavilla Jul 2, 2024
6ee5508
Update public/plugin.tsx
kavilla Jul 2, 2024
8bb83a1
fix linter
kavilla Jul 2, 2024
e5f626b
[MDS] datasource selector added
kavilla Jul 2, 2024
3543d51
add more tests for query assist (#31)
joshuali925 Jul 3, 2024
222b928
fix!: remove dataSource key in get connection response
joshuali925 Jul 3, 2024
9f43eba
change isEnabled to an observable based on selected connection
joshuali925 Jul 3, 2024
a43fcdc
protect duplicated calls
joshuali925 Jul 3, 2024
9306f14
test: Add mock-heavy tests for sql search strategy
kavilla Jul 8, 2024
468b74b
(Query assist) change isEnabled to an observable based on selected co…
kavilla Jul 8, 2024
9abc883
[build] import via start services
kavilla Jul 3, 2024
e2a1636
Add 'src/plugins/query_enhancements/' from commit '9abc883f56e1d032fd…
kavilla Jul 9, 2024
fdab7a2
Changeset file for PR #7212 created/updated
opensearch-changeset-bot[bot] Jul 9, 2024
dbf05b5
foobar
kavilla Jul 9, 2024
b398640
Merge branch 'query_enhancements' of github.com:kavilla/OpenSearch-Da…
kavilla Jul 10, 2024
f879c1b
updating imports still in progress
kavilla Jul 10, 2024
ece47d0
Update more imports
kavilla Jul 10, 2024
f58c4ba
fix setting of state
kavilla Jul 11, 2024
20411f1
fixes bugs
kavilla Jul 11, 2024
8a94a4b
Update test
kavilla Jul 16, 2024
6a1bfec
Merge remote-tracking branch 'upstream/main' into query_enhancements
kavilla Jul 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))
1 change: 1 addition & 0 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
- 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)
Expand Down
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';
20 changes: 9 additions & 11 deletions src/plugins/data/public/ui/query_editor/query_editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ export default class QueryEditorUI extends Component<Props, State> {
: undefined;
this.onChange(newQuery, dateRange);
this.onSubmit(newQuery, dateRange);
this.setState({ isDataSetsVisible: enhancement?.searchBar?.showDataSetsSelector ?? true });
this.setState({
isDataSourcesVisible: enhancement?.searchBar?.showDataSourcesSelector ?? true,
isDataSetsVisible: enhancement?.searchBar?.showDataSetsSelector ?? true,
});
};

Expand All @@ -231,19 +231,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
?.showDataSourcesSelector ?? true;
this.setState({ isDataSourcesVisible });
return this.props.settings.getQueryEnhancements(this.props.query.language)?.searchBar
?.showDataSourcesSelector;
};

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

const isDataSetsVisible =
this.props.settings.getQueryEnhancements(this.props.query.language)?.searchBar
?.showDataSetsSelector ?? true;
this.setState({ isDataSetsVisible });
return this.props.settings.getQueryEnhancements(this.props.query.language)?.searchBar
?.showDataSetsSelector;
};

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

this.initPersistedLog();
// this.fetchIndexPatterns().then(this.updateSuggestions);
this.initDataSourcesVisibility();
this.initDataSetsVisibility();
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
Copy link
Member

Choose a reason for hiding this comment

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

This Readme could use more data.

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';
19 changes: 19 additions & 0 deletions src/plugins/query_enhancements/common/query_assist/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { TimeRange } from 'src/plugins/data/common';

export interface QueryAssistResponse {
query: string;
timeRange?: TimeRange;
}

export interface QueryAssistParameters {
question: string;
index: string;
language: string;
// for MDS
dataSourceId?: string;
}
15 changes: 15 additions & 0 deletions src/plugins/query_enhancements/common/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { CoreSetup } from 'opensearch-dashboards/public';
import { Observable } from 'rxjs';

export interface FetchDataFrameContext {
http: CoreSetup['http'];
path: string;
signal?: AbortSignal;
}

export type FetchFunction<T, P = void> = (params?: P) => Observable<T>;
Loading
Loading