diff --git a/examples/search_explorer/public/es_strategy.tsx b/examples/search_explorer/public/es_strategy.tsx index 5d2617e64a79e..aaf9dada90341 100644 --- a/examples/search_explorer/public/es_strategy.tsx +++ b/examples/search_explorer/public/es_strategy.tsx @@ -33,8 +33,6 @@ import { import { DoSearch } from './do_search'; import { GuideSection } from './guide_section'; -// @ts-ignore -import serverPlugin from '!!raw-loader!./../../../src/plugins/data/server/search/es_search/es_search_service'; // @ts-ignore import serverStrategy from '!!raw-loader!./../../../src/plugins/data/server/search/es_search/es_search_strategy'; @@ -127,10 +125,7 @@ export class EsSearchTest extends React.Component { }, { title: 'Server', - code: [ - { description: 'es_search_service.ts', snippet: serverPlugin }, - { description: 'es_search_strategy.ts', snippet: serverStrategy }, - ], + code: [{ description: 'es_search_strategy.ts', snippet: serverStrategy }], }, ]} demo={this.renderDemo()} diff --git a/src/plugins/data/server/search/es_search/es_search_service.test.ts b/src/plugins/data/server/search/es_search/es_search_service.test.ts deleted file mode 100644 index 0b274c62958a9..0000000000000 --- a/src/plugins/data/server/search/es_search/es_search_service.test.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { coreMock } from '../../../../../core/server/mocks'; -import { EsSearchService } from './es_search_service'; -import { searchSetupMock } from '../mocks'; - -describe('ES search strategy service', () => { - let service: EsSearchService; - - const mockCoreSetup = coreMock.createSetup(); - const context = coreMock.createPluginInitializerContext(); - - beforeEach(() => { - service = new EsSearchService(context); - }); - - describe('setup()', () => { - it('registers the ES search strategy', async () => { - service.setup(mockCoreSetup, { - search: searchSetupMock, - }); - expect(searchSetupMock.registerSearchStrategyProvider).toBeCalled(); - }); - }); -}); diff --git a/src/plugins/data/server/search/es_search/es_search_service.ts b/src/plugins/data/server/search/es_search/es_search_service.ts deleted file mode 100644 index b33b6c6ecd318..0000000000000 --- a/src/plugins/data/server/search/es_search/es_search_service.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { ISearchSetup } from '../i_search_setup'; -import { PluginInitializerContext, CoreSetup, Plugin } from '../../../../../core/server'; -import { esSearchStrategyProvider } from './es_search_strategy'; -import { ES_SEARCH_STRATEGY } from '../../../common/search'; - -interface IEsSearchDependencies { - search: ISearchSetup; -} - -export class EsSearchService implements Plugin { - constructor(private initializerContext: PluginInitializerContext) {} - - public setup(core: CoreSetup, deps: IEsSearchDependencies) { - deps.search.registerSearchStrategyProvider( - this.initializerContext.opaqueId, - ES_SEARCH_STRATEGY, - esSearchStrategyProvider - ); - } - - public start() {} - public stop() {} -} diff --git a/src/plugins/data/server/search/es_search/index.ts b/src/plugins/data/server/search/es_search/index.ts index a1d4070114ad5..e5dcb0c97d7c9 100644 --- a/src/plugins/data/server/search/es_search/index.ts +++ b/src/plugins/data/server/search/es_search/index.ts @@ -17,11 +17,6 @@ * under the License. */ -import { PluginInitializerContext } from '../../../../../core/server'; -import { EsSearchService } from './es_search_service'; +export { esSearchStrategyProvider } from './es_search_strategy'; export { ES_SEARCH_STRATEGY, IEsSearchRequest, IEsSearchResponse } from '../../../common/search'; - -export function esSearchService(initializerContext: PluginInitializerContext) { - return new EsSearchService(initializerContext); -} diff --git a/src/plugins/data/server/search/i_search_setup.ts b/src/plugins/data/server/search/i_search_setup.ts index fb84cabfd37be..e4a4d50141201 100644 --- a/src/plugins/data/server/search/i_search_setup.ts +++ b/src/plugins/data/server/search/i_search_setup.ts @@ -17,12 +17,9 @@ * under the License. */ -import { IContextProvider, APICaller } from 'kibana/server'; +import { IContextProvider } from 'kibana/server'; import { ISearchContext } from './i_search_context'; -import { IResponseTypesMap, IRequestTypesMap } from './i_search'; import { TRegisterSearchStrategyProvider, TSearchStrategyProvider } from './i_search_strategy'; -import { TStrategyTypes } from './strategy_types'; -import { DEFAULT_SEARCH_STRATEGY } from '../../common/search'; /** * The setup contract exposed by the Search plugin exposes the search strategy extension @@ -40,12 +37,4 @@ export interface ISearchSetup { * strategies. */ registerSearchStrategyProvider: TRegisterSearchStrategyProvider; - - __LEGACY: { - search: ( - caller: APICaller, - request: IRequestTypesMap[T], - strategyName?: T - ) => Promise; - }; } diff --git a/src/plugins/data/server/search/search_service.test.ts b/src/plugins/data/server/search/search_service.test.ts index 2b5c144f8fa67..fa659756c1273 100644 --- a/src/plugins/data/server/search/search_service.test.ts +++ b/src/plugins/data/server/search/search_service.test.ts @@ -42,15 +42,6 @@ describe('Search service', () => { const setup = plugin.setup(mockCoreSetup); expect(setup).toHaveProperty('registerSearchStrategyContext'); expect(setup).toHaveProperty('registerSearchStrategyProvider'); - expect(setup).toHaveProperty('__LEGACY'); - }); - }); - - describe('__LEGACY', () => { - it('calls searchAPI.search', async () => { - const setup = plugin.setup(mockCoreSetup); - setup.__LEGACY.search(jest.fn(), {}, 'foo'); - expect(mockSearchApi.search).toBeCalled(); }); }); }); diff --git a/src/plugins/data/server/search/search_service.ts b/src/plugins/data/server/search/search_service.ts index 8ca314ad7bfd8..09bb150594177 100644 --- a/src/plugins/data/server/search/search_service.ts +++ b/src/plugins/data/server/search/search_service.ts @@ -32,7 +32,7 @@ import { TRegisterSearchStrategyProvider, } from './i_search_strategy'; import { IRouteHandlerSearchContext } from './i_route_handler_search_context'; -import { esSearchService } from './es_search'; +import { ES_SEARCH_STRATEGY, esSearchStrategyProvider } from './es_search'; declare module 'kibana/server' { interface RequestHandlerContext { @@ -71,15 +71,6 @@ export class SearchService implements Plugin { const api: ISearchSetup = { registerSearchStrategyContext: this.contextContainer!.registerContext, registerSearchStrategyProvider, - __LEGACY: { - search: (caller, request, strategyName) => { - const searchAPI = createApi({ - caller, - searchStrategies: this.searchStrategies, - }); - return searchAPI.search(request, {}, strategyName); - }, - }, }; api.registerSearchStrategyContext(this.initializerContext.opaqueId, 'core', () => core); @@ -89,10 +80,11 @@ export class SearchService implements Plugin { () => this.initializerContext.config.legacy.globalConfig$ ); - // ES search capabilities are written in a way that it could easily be a separate plugin, - // however these two plugins are tightly coupled due to the default search strategy using - // es search types. - esSearchService(this.initializerContext).setup(core, { search: api }); + api.registerSearchStrategyProvider( + this.initializerContext.opaqueId, + ES_SEARCH_STRATEGY, + esSearchStrategyProvider + ); return api; }