Skip to content

Commit

Permalink
Delete legacy search endpoint (#59341) (#59404)
Browse files Browse the repository at this point in the history
* Delete legacy search endpoint

* Fix example

* fix jest

Co-authored-by: Elastic Machine <[email protected]>

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
Liza Katz and elasticmachine authored Mar 5, 2020
1 parent 0342399 commit fcc65c8
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 131 deletions.
7 changes: 1 addition & 6 deletions examples/search_explorer/public/es_strategy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -127,10 +125,7 @@ export class EsSearchTest extends React.Component<Props, State> {
},
{
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()}
Expand Down
42 changes: 0 additions & 42 deletions src/plugins/data/server/search/es_search/es_search_service.test.ts

This file was deleted.

42 changes: 0 additions & 42 deletions src/plugins/data/server/search/es_search/es_search_service.ts

This file was deleted.

7 changes: 1 addition & 6 deletions src/plugins/data/server/search/es_search/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
13 changes: 1 addition & 12 deletions src/plugins/data/server/search/i_search_setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -40,12 +37,4 @@ export interface ISearchSetup {
* strategies.
*/
registerSearchStrategyProvider: TRegisterSearchStrategyProvider;

__LEGACY: {
search: <T extends TStrategyTypes = typeof DEFAULT_SEARCH_STRATEGY>(
caller: APICaller,
request: IRequestTypesMap[T],
strategyName?: T
) => Promise<IResponseTypesMap[T]>;
};
}
9 changes: 0 additions & 9 deletions src/plugins/data/server/search/search_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
});
20 changes: 6 additions & 14 deletions src/plugins/data/server/search/search_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -71,15 +71,6 @@ export class SearchService implements Plugin<ISearchSetup, void> {
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);
Expand All @@ -89,10 +80,11 @@ export class SearchService implements Plugin<ISearchSetup, void> {
() => 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;
}
Expand Down

0 comments on commit fcc65c8

Please sign in to comment.