This reverts commit 2ef7f3bd0c
.
This commit is contained in:
parent
c7aba55f7b
commit
7f740831cb
|
@ -14,6 +14,6 @@ export declare class IndexPatternsServiceProvider implements Plugin<void, IndexP
|
|||
|
||||
| Method | Modifiers | Description |
|
||||
| --- | --- | --- |
|
||||
| [setup(core, { logger, expressions })](./kibana-plugin-plugins-data-server.indexpatternsserviceprovider.setup.md) | | |
|
||||
| [setup(core, { expressions })](./kibana-plugin-plugins-data-server.indexpatternsserviceprovider.setup.md) | | |
|
||||
| [start(core, { fieldFormats, logger })](./kibana-plugin-plugins-data-server.indexpatternsserviceprovider.start.md) | | |
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
setup(core: CoreSetup<DataPluginStartDependencies, DataPluginStart>, { logger, expressions }: IndexPatternsServiceSetupDeps): void;
|
||||
setup(core: CoreSetup<DataPluginStartDependencies, DataPluginStart>, { expressions }: IndexPatternsServiceSetupDeps): void;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
@ -15,7 +15,7 @@ setup(core: CoreSetup<DataPluginStartDependencies, DataPluginStart>, { logger, e
|
|||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| core | <code>CoreSetup<DataPluginStartDependencies, DataPluginStart></code> | |
|
||||
| { logger, expressions } | <code>IndexPatternsServiceSetupDeps</code> | |
|
||||
| { expressions } | <code>IndexPatternsServiceSetupDeps</code> | |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
|
|
|
@ -109,5 +109,6 @@
|
|||
| [KibanaContext](./kibana-plugin-plugins-data-server.kibanacontext.md) | |
|
||||
| [ParsedInterval](./kibana-plugin-plugins-data-server.parsedinterval.md) | |
|
||||
| [Query](./kibana-plugin-plugins-data-server.query.md) | |
|
||||
| [SearchRequestHandlerContext](./kibana-plugin-plugins-data-server.searchrequesthandlercontext.md) | |
|
||||
| [TimeRange](./kibana-plugin-plugins-data-server.timerange.md) | |
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [SearchRequestHandlerContext](./kibana-plugin-plugins-data-server.searchrequesthandlercontext.md)
|
||||
|
||||
## SearchRequestHandlerContext type
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export declare type SearchRequestHandlerContext = IScopedSearchClient;
|
||||
```
|
|
@ -9,10 +9,9 @@
|
|||
import { Observable } from 'rxjs';
|
||||
import { CoreSetup, SharedGlobalConfig } from 'kibana/server';
|
||||
import { registerValueSuggestionsRoute } from './value_suggestions_route';
|
||||
import { DataRequestHandlerContext } from '../types';
|
||||
|
||||
export function registerRoutes({ http }: CoreSetup, config$: Observable<SharedGlobalConfig>): void {
|
||||
const router = http.createRouter<DataRequestHandlerContext>();
|
||||
const router = http.createRouter();
|
||||
|
||||
registerValueSuggestionsRoute(router, config$);
|
||||
}
|
||||
|
|
|
@ -12,12 +12,12 @@ import { IRouter, SharedGlobalConfig } from 'kibana/server';
|
|||
|
||||
import { Observable } from 'rxjs';
|
||||
import { first } from 'rxjs/operators';
|
||||
import { IFieldType, Filter, ES_SEARCH_STRATEGY, IEsSearchRequest } from '../index';
|
||||
import { IFieldType, Filter } from '../index';
|
||||
import { findIndexPatternById, getFieldByName } from '../index_patterns';
|
||||
import { getRequestAbortedSignal } from '../lib';
|
||||
import { DataRequestHandlerContext } from '../types';
|
||||
|
||||
export function registerValueSuggestionsRoute(
|
||||
router: IRouter<DataRequestHandlerContext>,
|
||||
router: IRouter,
|
||||
config$: Observable<SharedGlobalConfig>
|
||||
) {
|
||||
router.post(
|
||||
|
@ -44,40 +44,24 @@ export function registerValueSuggestionsRoute(
|
|||
const config = await config$.pipe(first()).toPromise();
|
||||
const { field: fieldName, query, filters } = request.body;
|
||||
const { index } = request.params;
|
||||
const { client } = context.core.elasticsearch.legacy;
|
||||
const signal = getRequestAbortedSignal(request.events.aborted$);
|
||||
|
||||
if (!context.indexPatterns) {
|
||||
return response.badRequest();
|
||||
}
|
||||
|
||||
const autocompleteSearchOptions = {
|
||||
timeout: `${config.kibana.autocompleteTimeout.asMilliseconds()}ms`,
|
||||
terminate_after: config.kibana.autocompleteTerminateAfter.asMilliseconds(),
|
||||
};
|
||||
|
||||
const indexPatterns = await context.indexPatterns.find(index, 1);
|
||||
if (!indexPatterns || indexPatterns.length === 0) {
|
||||
return response.notFound();
|
||||
}
|
||||
const field = indexPatterns[0].getFieldByName(fieldName);
|
||||
const indexPattern = await findIndexPatternById(context.core.savedObjects.client, index);
|
||||
|
||||
const field = indexPattern && getFieldByName(fieldName, indexPattern);
|
||||
const body = await getBody(autocompleteSearchOptions, field || fieldName, query, filters);
|
||||
|
||||
const searchRequest: IEsSearchRequest = {
|
||||
params: {
|
||||
index,
|
||||
body,
|
||||
},
|
||||
};
|
||||
const { rawResponse } = await context.search
|
||||
.search(searchRequest, {
|
||||
strategy: ES_SEARCH_STRATEGY,
|
||||
abortSignal: signal,
|
||||
})
|
||||
.toPromise();
|
||||
const result = await client.callAsCurrentUser('search', { index, body }, { signal });
|
||||
|
||||
const buckets: any[] =
|
||||
get(rawResponse, 'aggregations.suggestions.buckets') ||
|
||||
get(rawResponse, 'aggregations.nestedSuggestions.suggestions.buckets');
|
||||
get(result, 'aggregations.suggestions.buckets') ||
|
||||
get(result, 'aggregations.nestedSuggestions.suggestions.buckets');
|
||||
|
||||
return response.ok({ body: map(buckets || [], 'key') });
|
||||
}
|
||||
|
|
|
@ -236,10 +236,10 @@ export {
|
|||
SearchUsage,
|
||||
SearchSessionService,
|
||||
ISearchSessionService,
|
||||
SearchRequestHandlerContext,
|
||||
DataRequestHandlerContext,
|
||||
} from './search';
|
||||
|
||||
export { DataRequestHandlerContext } from './types';
|
||||
|
||||
// Search namespace
|
||||
export const search = {
|
||||
aggs: {
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { IndexPatternsService } from '../../common/index_patterns';
|
||||
|
||||
export * from './utils';
|
||||
export {
|
||||
IndexPatternsFetcher,
|
||||
|
@ -17,5 +15,3 @@ export {
|
|||
getCapabilitiesForRollupIndices,
|
||||
} from './fetcher';
|
||||
export { IndexPatternsServiceProvider, IndexPatternsServiceStart } from './index_patterns_service';
|
||||
|
||||
export type IndexPatternsHandlerContext = IndexPatternsService;
|
||||
|
|
|
@ -25,7 +25,6 @@ import { getIndexPatternLoad } from './expressions';
|
|||
import { UiSettingsServerToCommon } from './ui_settings_wrapper';
|
||||
import { IndexPatternsApiServer } from './index_patterns_api_client';
|
||||
import { SavedObjectsClientServerToCommon } from './saved_objects_client_wrapper';
|
||||
import { DataRequestHandlerContext } from '../types';
|
||||
|
||||
export interface IndexPatternsServiceStart {
|
||||
indexPatternsServiceFactory: (
|
||||
|
@ -36,7 +35,6 @@ export interface IndexPatternsServiceStart {
|
|||
|
||||
export interface IndexPatternsServiceSetupDeps {
|
||||
expressions: ExpressionsServerSetup;
|
||||
logger: Logger;
|
||||
}
|
||||
|
||||
export interface IndexPatternsServiceStartDeps {
|
||||
|
@ -47,27 +45,11 @@ export interface IndexPatternsServiceStartDeps {
|
|||
export class IndexPatternsServiceProvider implements Plugin<void, IndexPatternsServiceStart> {
|
||||
public setup(
|
||||
core: CoreSetup<DataPluginStartDependencies, DataPluginStart>,
|
||||
{ logger, expressions }: IndexPatternsServiceSetupDeps
|
||||
{ expressions }: IndexPatternsServiceSetupDeps
|
||||
) {
|
||||
core.savedObjects.registerType(indexPatternSavedObjectType);
|
||||
core.capabilities.registerProvider(capabilitiesProvider);
|
||||
|
||||
core.http.registerRouteHandlerContext<DataRequestHandlerContext, 'indexPatterns'>(
|
||||
'indexPatterns',
|
||||
async (context, request) => {
|
||||
const [coreStart, , dataStart] = await core.getStartServices();
|
||||
try {
|
||||
return await dataStart.indexPatterns.indexPatternsServiceFactory(
|
||||
coreStart.savedObjects.getScopedClient(request),
|
||||
coreStart.elasticsearch.client.asScoped(request).asCurrentUser
|
||||
);
|
||||
} catch (e) {
|
||||
logger.error(e);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
registerRoutes(core.http, core.getStartServices);
|
||||
|
||||
expressions.registerFunction(getIndexPatternLoad({ getStartServices: core.getStartServices }));
|
||||
|
|
|
@ -13,7 +13,7 @@ import {
|
|||
} from './search/mocks';
|
||||
import { createFieldFormatsSetupMock, createFieldFormatsStartMock } from './field_formats/mocks';
|
||||
import { createIndexPatternsStartMock } from './index_patterns/mocks';
|
||||
import { DataRequestHandlerContext } from './types';
|
||||
import { DataRequestHandlerContext } from './search';
|
||||
|
||||
function createSetupContract() {
|
||||
return {
|
||||
|
|
|
@ -82,10 +82,7 @@ export class DataServerPlugin
|
|||
this.queryService.setup(core);
|
||||
this.autocompleteService.setup(core);
|
||||
this.kqlTelemetryService.setup(core, { usageCollection });
|
||||
this.indexPatterns.setup(core, {
|
||||
expressions,
|
||||
logger: this.logger.get('indexPatterns'),
|
||||
});
|
||||
this.indexPatterns.setup(core, { expressions });
|
||||
|
||||
core.uiSettings.register(getUiSettings());
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import { SearchRouteDependencies } from '../search_service';
|
|||
|
||||
import { getCallMsearch } from './call_msearch';
|
||||
import { reportServerError } from '../../../../kibana_utils/server';
|
||||
import type { DataPluginRouter } from '../../types';
|
||||
import type { DataPluginRouter } from '../types';
|
||||
/**
|
||||
* The msearch route takes in an array of searches, each consisting of header
|
||||
* and body json, and reformts them into a single request for the _msearch API.
|
||||
|
|
|
@ -10,7 +10,7 @@ import { first } from 'rxjs/operators';
|
|||
import { schema } from '@kbn/config-schema';
|
||||
import { getRequestAbortedSignal } from '../../lib';
|
||||
import { reportServerError } from '../../../../kibana_utils/server';
|
||||
import type { DataPluginRouter } from '../../types';
|
||||
import type { DataPluginRouter } from '../types';
|
||||
|
||||
export function registerSearchRoute(router: DataPluginRouter): void {
|
||||
router.post(
|
||||
|
|
|
@ -29,6 +29,7 @@ import type {
|
|||
ISearchStrategy,
|
||||
SearchEnhancements,
|
||||
SearchStrategyDependencies,
|
||||
DataRequestHandlerContext,
|
||||
} from './types';
|
||||
|
||||
import { AggsService } from './aggs';
|
||||
|
@ -74,7 +75,6 @@ import { ConfigSchema } from '../../config';
|
|||
import { ISearchSessionService, SearchSessionService } from './session';
|
||||
import { KbnServerError } from '../../../kibana_utils/server';
|
||||
import { registerBsearchRoute } from './routes/bsearch';
|
||||
import { DataRequestHandlerContext } from '../types';
|
||||
|
||||
type StrategyMap = Record<string, ISearchStrategy<any, any>>;
|
||||
|
||||
|
|
|
@ -8,10 +8,12 @@
|
|||
|
||||
import { Observable } from 'rxjs';
|
||||
import type {
|
||||
IRouter,
|
||||
IScopedClusterClient,
|
||||
IUiSettingsClient,
|
||||
SavedObjectsClientContract,
|
||||
KibanaRequest,
|
||||
RequestHandlerContext,
|
||||
} from 'src/core/server';
|
||||
import {
|
||||
ISearchOptions,
|
||||
|
@ -114,3 +116,12 @@ export interface ISearchStart<
|
|||
}
|
||||
|
||||
export type SearchRequestHandlerContext = IScopedSearchClient;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export interface DataRequestHandlerContext extends RequestHandlerContext {
|
||||
search: SearchRequestHandlerContext;
|
||||
}
|
||||
|
||||
export type DataPluginRouter = IRouter<DataRequestHandlerContext>;
|
||||
|
|
|
@ -316,12 +316,6 @@ export const config: PluginConfigDescriptor<ConfigSchema>;
|
|||
|
||||
// @internal (undocumented)
|
||||
export interface DataRequestHandlerContext extends RequestHandlerContext {
|
||||
// Warning: (ae-forgotten-export) The symbol "IndexPatternsHandlerContext" needs to be exported by the entry point index.d.ts
|
||||
//
|
||||
// (undocumented)
|
||||
indexPatterns?: IndexPatternsHandlerContext;
|
||||
// Warning: (ae-forgotten-export) The symbol "SearchRequestHandlerContext" needs to be exported by the entry point index.d.ts
|
||||
//
|
||||
// (undocumented)
|
||||
search: SearchRequestHandlerContext;
|
||||
}
|
||||
|
@ -964,7 +958,7 @@ export class IndexPatternsServiceProvider implements Plugin_3<void, IndexPattern
|
|||
// Warning: (ae-forgotten-export) The symbol "IndexPatternsServiceSetupDeps" needs to be exported by the entry point index.d.ts
|
||||
//
|
||||
// (undocumented)
|
||||
setup(core: CoreSetup_2<DataPluginStartDependencies, PluginStart>, { logger, expressions }: IndexPatternsServiceSetupDeps): void;
|
||||
setup(core: CoreSetup_2<DataPluginStartDependencies, PluginStart>, { expressions }: IndexPatternsServiceSetupDeps): void;
|
||||
// Warning: (ae-forgotten-export) The symbol "IndexPatternsServiceStartDeps" needs to be exported by the entry point index.d.ts
|
||||
//
|
||||
// (undocumented)
|
||||
|
@ -1331,6 +1325,11 @@ export const search: {
|
|||
tabifyGetColumns: typeof tabifyGetColumns;
|
||||
};
|
||||
|
||||
// Warning: (ae-missing-release-tag) "SearchRequestHandlerContext" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
export type SearchRequestHandlerContext = IScopedSearchClient;
|
||||
|
||||
// @internal
|
||||
export class SearchSessionService implements ISearchSessionService {
|
||||
constructor();
|
||||
|
@ -1522,7 +1521,7 @@ export function usageProvider(core: CoreSetup_2): SearchUsage;
|
|||
// src/plugins/data/server/index.ts:270:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts
|
||||
// src/plugins/data/server/index.ts:271:1 - (ae-forgotten-export) The symbol "calcAutoIntervalLessThan" needs to be exported by the entry point index.d.ts
|
||||
// src/plugins/data/server/plugin.ts:79:74 - (ae-forgotten-export) The symbol "DataEnhancements" needs to be exported by the entry point index.d.ts
|
||||
// src/plugins/data/server/search/types.ts:112:5 - (ae-forgotten-export) The symbol "ISearchStartSearchSource" needs to be exported by the entry point index.d.ts
|
||||
// src/plugins/data/server/search/types.ts:114:5 - (ae-forgotten-export) The symbol "ISearchStartSearchSource" needs to be exported by the entry point index.d.ts
|
||||
|
||||
// (No @packageDocumentation comment for this package)
|
||||
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
/*
|
||||
* 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 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import type { IRouter, RequestHandlerContext } from 'src/core/server';
|
||||
|
||||
import { SearchRequestHandlerContext } from './search';
|
||||
import { IndexPatternsHandlerContext } from './index_patterns';
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export interface DataRequestHandlerContext extends RequestHandlerContext {
|
||||
search: SearchRequestHandlerContext;
|
||||
indexPatterns?: IndexPatternsHandlerContext;
|
||||
}
|
||||
|
||||
export type DataPluginRouter = IRouter<DataRequestHandlerContext>;
|
|
@ -5,7 +5,8 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import type { DataRequestHandlerContext } from '../../../../src/plugins/data/server';
|
||||
import type { RequestHandlerContext } from 'src/core/server';
|
||||
import type { SearchRequestHandlerContext } from '../../../../src/plugins/data/server';
|
||||
import { MlPluginSetup } from '../../ml/server';
|
||||
|
||||
export type MlSystem = ReturnType<MlPluginSetup['mlSystemProvider']>;
|
||||
|
@ -26,6 +27,7 @@ export type InfraRequestHandlerContext = InfraMlRequestHandlerContext &
|
|||
/**
|
||||
* @internal
|
||||
*/
|
||||
export interface InfraPluginRequestHandlerContext extends DataRequestHandlerContext {
|
||||
export interface InfraPluginRequestHandlerContext extends RequestHandlerContext {
|
||||
infra: InfraRequestHandlerContext;
|
||||
search: SearchRequestHandlerContext;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue