Skip to content

Commit

Permalink
adding generic ml index search
Browse files Browse the repository at this point in the history
  • Loading branch information
jgowdyelastic committed Mar 10, 2020
1 parent 631adfe commit f8f15e7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions x-pack/plugins/ml/server/shared_services/providers/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
*/

import { APICaller } from 'kibana/server';
import { SearchResponse, SearchParams } from 'elasticsearch';
import { MlServerLicense } from '../../lib/license';
import { CloudSetup } from '../../../../cloud/server';
import { LicenseCheck } from '../license_checks';
import { spacesUtilsProvider, RequestFacade } from '../../lib/spaces_utils';
import { SpacesPluginSetup } from '../../../../spaces/server';
import { privilegesProvider, MlCapabilities } from '../../lib/check_privileges';
import { MlInfoResponse } from '../../../../../legacy/plugins/ml/common/types/ml_server_info';
import { ML_RESULTS_INDEX_PATTERN } from '../../../../../legacy/plugins/ml/common/constants/index_patterns';

export interface MlSystemProvider {
mlSystemProvider(
Expand All @@ -20,11 +22,13 @@ export interface MlSystemProvider {
): {
mlCapabilities(ignoreSpaces?: boolean): Promise<MlCapabilities>;
mlInfo(): Promise<MlInfoResponse>;
mlSearch<T>(searchParams: SearchParams): Promise<SearchResponse<T>>;
};
}

export function getMlSystemProvider(
isMinimumLicense: LicenseCheck,
isFullLicense: LicenseCheck,
mlLicense: MlServerLicense,
spaces: SpacesPluginSetup | undefined,
cloud: CloudSetup
Expand Down Expand Up @@ -57,6 +61,13 @@ export function getMlSystemProvider(
cloudId,
};
},
async mlSearch<T>(searchParams: SearchParams): Promise<SearchResponse<T>> {
isFullLicense();
return callAsCurrentUser('search', {
...searchParams,
index: ML_RESULTS_INDEX_PATTERN,
});
},
};
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function createSharedServices(
return {
...getJobServiceProvider(isFullLicense),
...getAnomalyDetectorsProvider(isFullLicense),
...getMlSystemProvider(isMinimumLicense, mlLicense, spaces, cloud),
...getMlSystemProvider(isMinimumLicense, isFullLicense, mlLicense, spaces, cloud),
...getModulesProvider(isFullLicense),
...getResultsServiceProvider(isFullLicense),
};
Expand Down

0 comments on commit f8f15e7

Please sign in to comment.