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

[Synonyms UI] Synonyms UI base plugin #203284

Merged
merged 23 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1b9cbcd
Add synonyms plugin and add routes
efegurkan Dec 4, 2024
97c8d0a
Check config before registering
efegurkan Dec 6, 2024
3c4c114
Merge branch 'main' of github.com:elastic/kibana into synonyms-ui-bas…
efegurkan Dec 17, 2024
ac08dfa
Update navigation on synonyms plugins
efegurkan Dec 17, 2024
0706eca
Fix missing config export
efegurkan Dec 17, 2024
ba7c1f4
Fix quick check failures
efegurkan Dec 17, 2024
7cf6cf1
FTR fixes
efegurkan Dec 17, 2024
78c132c
Review changes
efegurkan Dec 23, 2024
88404f4
Merge branch 'main' into synonyms-ui-base-plugin
elasticmachine Dec 23, 2024
807c206
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Dec 23, 2024
9bcf377
Fix FTRs
efegurkan Dec 23, 2024
e43981a
Fix privilege FTR
efegurkan Dec 23, 2024
2dc16b4
Merge branch 'main' of github.com:elastic/kibana into synonyms-ui-bas…
efegurkan Jan 2, 2025
4097ac5
Rebase and review changes
efegurkan Jan 2, 2025
eeefab0
[CI] Auto-commit changed files from 'node scripts/generate codeowners'
kibanamachine Jan 2, 2025
1a609df
Update tsconfig base path
efegurkan Jan 2, 2025
268d63f
Merge branch 'synonyms-ui-base-plugin' of github.com:efegurkan/kibana…
efegurkan Jan 2, 2025
cafd722
Fix types
efegurkan Jan 2, 2025
c32620e
Fix checks
efegurkan Jan 2, 2025
8500b3a
Merge branch 'main' of github.com:elastic/kibana into synonyms-ui-bas…
efegurkan Jan 6, 2025
b5b5df3
Remove wrongfully added lines due to merge conflict
efegurkan Jan 6, 2025
2e4e87f
[CI] Auto-commit changed files from 'node scripts/build_plugin_list_d…
kibanamachine Jan 6, 2025
804f38d
Merge branch 'main' into synonyms-ui-base-plugin
elasticmachine Jan 6, 2025
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
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,7 @@ x-pack/solutions/search/plugins/search_inference_endpoints @elastic/search-kiban
x-pack/solutions/search/plugins/search_notebooks @elastic/search-kibana
x-pack/solutions/search/plugins/search_playground @elastic/search-kibana
x-pack/solutions/search/plugins/search_solution/search_navigation @elastic/search-kibana
x-pack/solutions/search/plugins/search_synonyms @elastic/search-kibana
x-pack/solutions/search/plugins/serverless_search @elastic/search-kibana
x-pack/solutions/security/packages/data_table @elastic/security-threat-hunting-investigations
x-pack/solutions/security/packages/data-stream-adapter @elastic/security-threat-hunting
Expand Down
1 change: 1 addition & 0 deletions config/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ xpack.fleet.internal.activeAgentsSoftLimit: 25000
xpack.fleet.internal.onlyAllowAgentUpgradeToKnownVersions: true
xpack.fleet.internal.retrySetupOnBoot: true
xpack.fleet.internal.useMeteringApi: true
xpack.searchSynonyms.enabled: false

## Fine-tune the feature privileges.
xpack.features.overrides:
Expand Down
4 changes: 4 additions & 0 deletions docs/developer/plugin-list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,10 @@ detailed information on how Elasticsearch executed the search request. People us
to understand why a search request might be slow.


|{kib-repo}blob/{branch}/x-pack/solutions/search/plugins/search_synonyms/README.md[searchSynonyms]
|A plugin to manage synonyms in Elasticsearch through Synonyms APIs through Kibana.


|{kib-repo}blob/{branch}/x-pack/platform/plugins/shared/security/README.md[security]
|See Configuring security in
Kibana.
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,7 @@
"@kbn/search-playground": "link:x-pack/solutions/search/plugins/search_playground",
"@kbn/search-response-warnings": "link:src/platform/packages/shared/kbn-search-response-warnings",
"@kbn/search-shared-ui": "link:x-pack/solutions/search/packages/search/shared_ui",
"@kbn/search-synonyms": "link:x-pack/solutions/search/plugins/search_synonyms",
"@kbn/search-types": "link:src/platform/packages/shared/kbn-search-types",
"@kbn/searchprofiler-plugin": "link:x-pack/platform/plugins/shared/searchprofiler",
"@kbn/security-api-key-management": "link:x-pack/platform/packages/shared/security/api_key_management",
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ pageLoadAssetSize:
searchNotebooks: 18942
searchPlayground: 19325
searchprofiler: 67080
searchSynonyms: 20262
security: 81771
securitySolution: 98429
securitySolutionEss: 31781
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const SERVERLESS_ES_CONNECTORS_ID = 'serverlessConnectors';
export const SERVERLESS_ES_WEB_CRAWLERS_ID = 'serverlessWebCrawlers';
export const ES_SEARCH_PLAYGROUND_ID = 'searchPlayground';
export const SERVERLESS_ES_SEARCH_INFERENCE_ENDPOINTS_ID = 'searchInferenceEndpoints';
export const ES_SEARCH_SYNONYMS_ID = 'searchSynonyms';
export const SEARCH_HOMEPAGE = 'searchHomepage';
export const SEARCH_INDICES_START = 'elasticsearchStart';
export const SEARCH_INDICES = 'elasticsearchIndices';
Expand Down
6 changes: 6 additions & 0 deletions src/platform/packages/shared/deeplinks/search/deep_links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
SEARCH_VECTOR_SEARCH,
SEARCH_SEMANTIC_SEARCH,
SEARCH_AI_SEARCH,
ES_SEARCH_SYNONYMS_ID,
} from './constants';

export type EnterpriseSearchApp = typeof ENTERPRISE_SEARCH_APP_ID;
Expand All @@ -40,6 +41,7 @@ export type ConnectorsId = typeof SERVERLESS_ES_CONNECTORS_ID;
export type ServerlessWebCrawlers = typeof SERVERLESS_ES_WEB_CRAWLERS_ID;
export type SearchPlaygroundId = typeof ES_SEARCH_PLAYGROUND_ID;
export type SearchInferenceEndpointsId = typeof SERVERLESS_ES_SEARCH_INFERENCE_ENDPOINTS_ID;
export type SearchSynonymsId = typeof ES_SEARCH_SYNONYMS_ID;
export type SearchHomepage = typeof SEARCH_HOMEPAGE;
export type SearchStart = typeof SEARCH_INDICES_START;
export type SearchIndices = typeof SEARCH_INDICES;
Expand All @@ -56,6 +58,8 @@ export type AppsearchLinkId = 'engines';

export type SearchInferenceEndpointsLinkId = 'inferenceEndpoints';

export type SynonymsLinkId = 'synonyms';

export type SearchIndicesLinkId = typeof SEARCH_INDICES_CREATE_INDEX;

export type DeepLinkId =
Expand All @@ -70,11 +74,13 @@ export type DeepLinkId =
| ServerlessWebCrawlers
| SearchPlaygroundId
| SearchInferenceEndpointsId
| SearchSynonymsId
| SearchHomepage
| `${EnterpriseSearchContentApp}:${ContentLinkId}`
| `${EnterpriseSearchApplicationsApp}:${ApplicationsLinkId}`
| `${EnterpriseSearchAppsearchApp}:${AppsearchLinkId}`
| `${SearchInferenceEndpointsId}:${SearchInferenceEndpointsLinkId}`
| `${SearchSynonymsId}:${SynonymsLinkId}`
| SearchStart
| SearchIndices
| SearchElasticsearch
Expand Down
2 changes: 2 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -1606,6 +1606,8 @@
"@kbn/search-response-warnings/*": ["src/platform/packages/shared/kbn-search-response-warnings/*"],
"@kbn/search-shared-ui": ["x-pack/solutions/search/packages/search/shared_ui"],
"@kbn/search-shared-ui/*": ["x-pack/solutions/search/packages/search/shared_ui/*"],
"@kbn/search-synonyms": ["x-pack/solutions/search/plugins/search_synonyms"],
"@kbn/search-synonyms/*": ["x-pack/solutions/search/plugins/search_synonyms/*"],
"@kbn/search-types": ["src/platform/packages/shared/kbn-search-types"],
"@kbn/search-types/*": ["src/platform/packages/shared/kbn-search-types/*"],
"@kbn/searchprofiler-plugin": ["x-pack/platform/plugins/shared/searchprofiler"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ export const buildBaseClassicNavItems = (): ClassicNavItem[] => {
},
id: 'inference_endpoints',
},
{
'data-test-subj': 'searchSideNav-Synonyms',
deepLink: {
link: 'searchSynonyms:synonyms',
shouldShowActiveForSubroutes: true,
},
id: 'synonyms',
},
],
name: i18n.translate('xpack.enterpriseSearch.nav.relevanceTitle', {
defaultMessage: 'Relevance',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,10 @@ export const getNavigationTreeDefinition = ({
}),
},
{
children: [{ link: 'searchInferenceEndpoints:inferenceEndpoints' }],
children: [
{ link: 'searchInferenceEndpoints:inferenceEndpoints' },
{ link: 'searchSynonyms:synonyms' },
],
id: 'relevance',
title: i18n.translate('xpack.enterpriseSearch.searchNav.relevance', {
defaultMessage: 'Relevance',
Expand Down
3 changes: 3 additions & 0 deletions x-pack/solutions/search/plugins/search_synonyms/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Search Synonyms

A plugin to manage synonyms in Elasticsearch through Synonyms APIs through Kibana.
15 changes: 15 additions & 0 deletions x-pack/solutions/search/plugins/search_synonyms/common/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { i18n } from '@kbn/i18n';

export const PLUGIN_ID = 'searchSynonyms';
export const PLUGIN_NAME = 'Synonyms';

export const PLUGIN_TITLE = i18n.translate('xpack.searchSynonyms.pluginTitle', {
defaultMessage: 'Synonyms',
});
19 changes: 19 additions & 0 deletions x-pack/solutions/search/plugins/search_synonyms/common/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface SearchSynonymsPluginSetup {}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface SearchSynonymsPluginStart {}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface AppPluginSetupDependencies {}

export interface SearchSynonymsConfigType {
enabled: boolean;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

export const SYNONYMS_UI_FLAG = 'searchSynonyms:synonymsEnabled';
17 changes: 17 additions & 0 deletions x-pack/solutions/search/plugins/search_synonyms/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

module.exports = {
preset: '@kbn/test',
rootDir: '../../../../..',
roots: ['<rootDir>/x-pack/solutions/search/plugins/search_synonyms'],
coverageDirectory: '<rootDir>/target/kibana-coverage/jest/x-pack/plugins/search_synonyms',
coverageReporters: ['text', 'html'],
collectCoverageFrom: [
'<rootDir>/x-pack/solutions/search/plugins/search_synonyms/{public,server}/**/*.{ts,tsx}',
],
};
26 changes: 26 additions & 0 deletions x-pack/solutions/search/plugins/search_synonyms/kibana.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"type": "plugin",
"id": "@kbn/search-synonyms",
"owner": "@elastic/search-kibana",
"group": "search",
"visibility": "private",
"plugin": {
"id": "searchSynonyms",
"server": true,
"browser": true,
"configPath": [
"xpack",
"searchSynonyms"
],
"requiredPlugins": [
"features",
],
"optionalPlugins": [
"console",
"searchNavigation",
],
"requiredBundles": [
"kibanaReact",
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import React from 'react';
import ReactDOM from 'react-dom';
import { CoreStart } from '@kbn/core/public';
import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render';
import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public';
import { I18nProvider } from '@kbn/i18n-react';
import { Router } from '@kbn/shared-ux-router';
import { AppPluginStartDependencies } from './types';

export const renderApp = async (
core: CoreStart,
services: AppPluginStartDependencies,
element: HTMLElement
) => {
ReactDOM.render(
<KibanaRenderContextProvider {...core}>
<KibanaContextProvider services={{ ...core, ...services }}>
<I18nProvider>
<Router history={services.history}>
<div>Synonyms</div>
</Router>
</I18nProvider>
</KibanaContextProvider>
</KibanaRenderContextProvider>,
element
);
return () => ReactDOM.unmountComponentAtNode(element);
};
12 changes: 12 additions & 0 deletions x-pack/solutions/search/plugins/search_synonyms/public/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { SearchSynonymsPlugin } from './plugin';

export function plugin() {
return new SearchSynonymsPlugin();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import type { CoreSetup, Plugin, AppMountParameters } from '@kbn/core/public';
import { PLUGIN_ID, PLUGIN_NAME, PLUGIN_TITLE } from '../common';
import {
AppPluginSetupDependencies,
AppPluginStartDependencies,
SearchSynonymsPluginSetup,
SearchSynonymsPluginStart,
} from './types';
import { SYNONYMS_UI_FLAG } from '../common/ui_flags';

export class SearchSynonymsPlugin
implements Plugin<SearchSynonymsPluginSetup, SearchSynonymsPluginStart>
{
constructor() {}

public setup(
core: CoreSetup<AppPluginStartDependencies, SearchSynonymsPluginStart>,
_: AppPluginSetupDependencies
): SearchSynonymsPluginSetup {
if (!core.settings.client.get<boolean>(SYNONYMS_UI_FLAG, false)) {
return {};
}
core.application.register({
id: PLUGIN_ID,
appRoute: '/app/elasticsearch/synonyms',
title: PLUGIN_TITLE,
deepLinks: [
{
id: 'synonyms',
path: '/',
title: PLUGIN_TITLE,
visibleIn: ['globalSearch'],
},
],
async mount({ element, history }: AppMountParameters) {
const { renderApp } = await import('./application');
const [coreStart, depsStart] = await core.getStartServices();

coreStart.chrome.docTitle.change(PLUGIN_NAME);

const startDeps: AppPluginStartDependencies = {
...depsStart,
history,
};

depsStart.searchNavigation?.handleOnAppMount();

return renderApp(coreStart, startDeps, element);
},
visibleIn: [],
});

return {};
}

public start(): SearchSynonymsPluginStart {
return {};
}

public stop() {}
}
17 changes: 17 additions & 0 deletions x-pack/solutions/search/plugins/search_synonyms/public/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { SearchNavigationPluginStart } from '@kbn/search-navigation/public';
import { AppMountParameters } from '@kbn/core/public';
import type { ConsolePluginStart } from '@kbn/console-plugin/public';

export * from '../common/types';
export interface AppPluginStartDependencies {
history: AppMountParameters['history'];
console?: ConsolePluginStart;
searchNavigation?: SearchNavigationPluginStart;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { schema, TypeOf } from '@kbn/config-schema';
import { PluginConfigDescriptor } from '@kbn/core/server';

const configSchema = schema.object({
enabled: schema.boolean({ defaultValue: false }),
});

export type SearchPlaygroundConfig = TypeOf<typeof configSchema>;

export const config: PluginConfigDescriptor<SearchPlaygroundConfig> = {
schema: configSchema,
};
17 changes: 17 additions & 0 deletions x-pack/solutions/search/plugins/search_synonyms/server/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { PluginInitializerContext } from '@kbn/core/server';

export { config } from './config';

export async function plugin(initializerContext: PluginInitializerContext) {
const { SearchSynonymsPlugin } = await import('./plugin');
return new SearchSynonymsPlugin(initializerContext);
}

export type { SearchSynonymsPluginSetup, SearchSynonymsPluginStart } from './types';
Loading
Loading