mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 01:13:23 -04:00
[Search] Providing all connectors to the search results (#211213)
## Summary All search connectors are provided to the top global search bar from the Enterprise Search plugin. Taking users to the connectors creation flow in Search where only self-managed will be the option available and preselected by default tackled in this another PR https://github.com/elastic/kibana/pull/211206 Additionally we should not provide the same connectors coming from Integrations in order to avoid duplicated listed connectors as displayed in the screenshot, this should be done in this related issue: https://github.com/elastic/search-team/issues/9287  ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) ### Identify risks Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss. Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging. - [ ] [See some risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) - [ ] ... --------- Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
82f7aa3b19
commit
0c69f75a37
3 changed files with 25 additions and 39 deletions
|
@ -117,7 +117,6 @@ export class EnterpriseSearchPlugin implements Plugin<void, void, PluginsSetup,
|
|||
SEARCH_INDICES,
|
||||
SEARCH_INDICES_START,
|
||||
];
|
||||
const isCloud = !!cloud?.cloudId;
|
||||
|
||||
if (customIntegrations) {
|
||||
registerEnterpriseSearchIntegrations(
|
||||
|
@ -315,7 +314,7 @@ export class EnterpriseSearchPlugin implements Plugin<void, void, PluginsSetup,
|
|||
|
||||
if (globalSearch) {
|
||||
globalSearch.registerResultProvider(
|
||||
getSearchResultProvider(config, searchConnectors?.getConnectorTypes() || [], isCloud)
|
||||
getSearchResultProvider(config, searchConnectors?.getConnectorTypes() || [])
|
||||
);
|
||||
globalSearch.registerResultProvider(getIndicesSearchResultProvider(http.staticAssets));
|
||||
globalSearch.registerResultProvider(getConnectorsSearchResultProvider(http.staticAssets));
|
||||
|
|
|
@ -74,7 +74,19 @@ describe('Search search provider', () => {
|
|||
title: 'Customized connector',
|
||||
type: 'Elasticsearch',
|
||||
url: {
|
||||
path: `${ENTERPRISE_SEARCH_CONTENT_PLUGIN.URL}/connectors/select_connector?connector_type=connector_client&service_type=`,
|
||||
path: `${ENTERPRISE_SEARCH_CONTENT_PLUGIN.URL}/connectors/select_connector`,
|
||||
prependBasePath: true,
|
||||
},
|
||||
};
|
||||
|
||||
const mongodbConnectorResult = {
|
||||
icon: 'mongodb.svg',
|
||||
id: 'mongodb',
|
||||
score: 75,
|
||||
title: 'MongoDB',
|
||||
type: 'Elasticsearch',
|
||||
url: {
|
||||
path: `${ENTERPRISE_SEARCH_CONTENT_PLUGIN.URL}/connectors/select_connector`,
|
||||
prependBasePath: true,
|
||||
},
|
||||
};
|
||||
|
@ -95,8 +107,7 @@ describe('Search search provider', () => {
|
|||
{
|
||||
hasConnectors: true,
|
||||
} as any,
|
||||
connectors,
|
||||
false
|
||||
connectors
|
||||
);
|
||||
|
||||
beforeEach(() => {});
|
||||
|
@ -132,7 +143,7 @@ describe('Search search provider', () => {
|
|||
mockSearchProviderContext
|
||||
)
|
||||
).toBe('(a|)', {
|
||||
a: expect.arrayContaining([{ ...customizedConnectorResult, score: 80 }]),
|
||||
a: expect.arrayContaining([{ ...mongodbConnectorResult, score: 80 }]),
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -142,8 +153,7 @@ describe('Search search provider', () => {
|
|||
{
|
||||
hasConnectors: false,
|
||||
} as any,
|
||||
connectors,
|
||||
false
|
||||
connectors
|
||||
);
|
||||
getTestScheduler().run(({ expectObservable }) => {
|
||||
expectObservable(
|
||||
|
@ -203,8 +213,7 @@ describe('Search search provider', () => {
|
|||
{
|
||||
hasConnectors: false,
|
||||
} as any,
|
||||
connectors,
|
||||
false
|
||||
connectors
|
||||
);
|
||||
getTestScheduler().run(({ expectObservable }) => {
|
||||
expectObservable(
|
||||
|
@ -223,8 +232,7 @@ describe('Search search provider', () => {
|
|||
{
|
||||
hasConnectors: false,
|
||||
} as any,
|
||||
connectors,
|
||||
false
|
||||
connectors
|
||||
);
|
||||
getTestScheduler().run(({ expectObservable }) => {
|
||||
expectObservable(
|
||||
|
@ -244,8 +252,7 @@ describe('Search search provider', () => {
|
|||
{
|
||||
hasConnectors: true,
|
||||
} as any,
|
||||
connectors,
|
||||
true
|
||||
connectors
|
||||
);
|
||||
getTestScheduler().run(({ expectObservable }) => {
|
||||
expectObservable(
|
||||
|
|
|
@ -12,11 +12,7 @@ import { i18n } from '@kbn/i18n';
|
|||
import { ConnectorServerSideDefinition } from '@kbn/search-connectors';
|
||||
|
||||
import { ConfigType } from '..';
|
||||
import {
|
||||
ENTERPRISE_SEARCH_CONNECTOR_CRAWLER_SERVICE_TYPE,
|
||||
ENTERPRISE_SEARCH_CONTENT_PLUGIN,
|
||||
AI_SEARCH_PLUGIN,
|
||||
} from '../../common/constants';
|
||||
import { ENTERPRISE_SEARCH_CONTENT_PLUGIN, AI_SEARCH_PLUGIN } from '../../common/constants';
|
||||
|
||||
type ServiceDefinition =
|
||||
| ConnectorServerSideDefinition
|
||||
|
@ -31,30 +27,18 @@ type ServiceDefinition =
|
|||
|
||||
export function toSearchResult({
|
||||
iconPath,
|
||||
isCloud,
|
||||
isNative,
|
||||
name,
|
||||
score,
|
||||
serviceType,
|
||||
url,
|
||||
}: {
|
||||
iconPath?: string;
|
||||
isCloud: boolean;
|
||||
isNative?: boolean;
|
||||
name: string;
|
||||
score: number;
|
||||
serviceType: string;
|
||||
url?: string;
|
||||
}) {
|
||||
const isCrawler = serviceType === ENTERPRISE_SEARCH_CONNECTOR_CRAWLER_SERVICE_TYPE;
|
||||
const connectorTypeParam = !isCrawler
|
||||
? isCloud && isNative
|
||||
? 'native'
|
||||
: 'connector_client'
|
||||
: null;
|
||||
const newUrl = isCrawler
|
||||
? `${ENTERPRISE_SEARCH_CONTENT_PLUGIN.URL}/crawlers/new_crawler`
|
||||
: `${ENTERPRISE_SEARCH_CONTENT_PLUGIN.URL}/connectors/select_connector?connector_type=${connectorTypeParam}&service_type=${serviceType}`;
|
||||
const newUrl = `${ENTERPRISE_SEARCH_CONTENT_PLUGIN.URL}/connectors/select_connector`;
|
||||
|
||||
return {
|
||||
icon: iconPath || 'logoEnterpriseSearch',
|
||||
|
@ -71,8 +55,7 @@ export function toSearchResult({
|
|||
|
||||
export function getSearchResultProvider(
|
||||
config: ConfigType,
|
||||
connectorTypes: ConnectorServerSideDefinition[],
|
||||
isCloud: boolean
|
||||
connectorTypes: ConnectorServerSideDefinition[]
|
||||
): GlobalSearchResultProvider {
|
||||
return {
|
||||
find: ({ term, types, tags }, { aborted$, maxResults }, { core: { capabilities } }) => {
|
||||
|
@ -89,9 +72,8 @@ export function getSearchResultProvider(
|
|||
if (!caps.catalogue.enterpriseSearch) {
|
||||
return [];
|
||||
}
|
||||
const selfManagedConnectors = connectorTypes.filter((connector) => !connector.isNative);
|
||||
const services: ServiceDefinition[] = [
|
||||
...(config.hasConnectors ? selfManagedConnectors : []),
|
||||
...(config.hasConnectors ? connectorTypes : []),
|
||||
|
||||
{
|
||||
keywords: ['esre', 'search'],
|
||||
|
@ -104,7 +86,7 @@ export function getSearchResultProvider(
|
|||
];
|
||||
const result = services
|
||||
.map((service) => {
|
||||
const { isNative, iconPath, name, keywords, serviceType } = service;
|
||||
const { iconPath, name, keywords, serviceType } = service;
|
||||
const url = 'url' in service ? service.url : undefined;
|
||||
let score = 0;
|
||||
const searchTerm = (term || '').toLowerCase();
|
||||
|
@ -124,8 +106,6 @@ export function getSearchResultProvider(
|
|||
}
|
||||
return toSearchResult({
|
||||
iconPath,
|
||||
isCloud,
|
||||
isNative,
|
||||
name,
|
||||
score,
|
||||
serviceType,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue