mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
* wip: pull out all server dependencies * create new platform plugin * shim newPlatform plugin into legacy init * update server tests for migration refactor * cleanup interfaces * Only add ML links for sample data sets if full license from - 38120 * update test and fix typescript errors * Remove unused types
114 lines
2.7 KiB
JavaScript
114 lines
2.7 KiB
JavaScript
/*
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
* or more contributor license agreements. Licensed under the Elastic License;
|
|
* you may not use this file except in compliance with the Elastic License.
|
|
*/
|
|
|
|
|
|
|
|
import { callWithRequestFactory } from '../client/call_with_request_factory';
|
|
import { wrapError } from '../client/errors';
|
|
import { DataVisualizer } from '../models/data_visualizer';
|
|
|
|
|
|
function getOverallStats(
|
|
callWithRequest,
|
|
indexPatternTitle,
|
|
query,
|
|
aggregatableFields,
|
|
nonAggregatableFields,
|
|
samplerShardSize,
|
|
timeFieldName,
|
|
earliestMs,
|
|
latestMs) {
|
|
const dv = new DataVisualizer(callWithRequest);
|
|
return dv.getOverallStats(
|
|
indexPatternTitle,
|
|
query,
|
|
aggregatableFields,
|
|
nonAggregatableFields,
|
|
samplerShardSize,
|
|
timeFieldName,
|
|
earliestMs,
|
|
latestMs
|
|
);
|
|
}
|
|
|
|
function getStatsForFields(
|
|
callWithRequest,
|
|
indexPatternTitle,
|
|
query,
|
|
fields,
|
|
samplerShardSize,
|
|
timeFieldName,
|
|
earliestMs,
|
|
latestMs,
|
|
interval,
|
|
maxExamples) {
|
|
const dv = new DataVisualizer(callWithRequest);
|
|
return dv.getStatsForFields(
|
|
indexPatternTitle,
|
|
query,
|
|
fields,
|
|
samplerShardSize,
|
|
timeFieldName,
|
|
earliestMs,
|
|
latestMs,
|
|
interval,
|
|
maxExamples
|
|
);
|
|
}
|
|
|
|
|
|
export function dataVisualizerRoutes({ commonRouteConfig, elasticsearchPlugin, route }) {
|
|
|
|
route({
|
|
method: 'POST',
|
|
path: '/api/ml/data_visualizer/get_field_stats/{indexPatternTitle}',
|
|
handler(request) {
|
|
const callWithRequest = callWithRequestFactory(elasticsearchPlugin, request);
|
|
const indexPatternTitle = request.params.indexPatternTitle;
|
|
const payload = request.payload;
|
|
return getStatsForFields(
|
|
callWithRequest,
|
|
indexPatternTitle,
|
|
payload.query,
|
|
payload.fields,
|
|
payload.samplerShardSize,
|
|
payload.timeFieldName,
|
|
payload.earliest,
|
|
payload.latest,
|
|
payload.interval,
|
|
payload.maxExamples)
|
|
.catch(resp => wrapError(resp));
|
|
},
|
|
config: {
|
|
...commonRouteConfig
|
|
}
|
|
});
|
|
|
|
route({
|
|
method: 'POST',
|
|
path: '/api/ml/data_visualizer/get_overall_stats/{indexPatternTitle}',
|
|
handler(request) {
|
|
const callWithRequest = callWithRequestFactory(elasticsearchPlugin, request);
|
|
const indexPatternTitle = request.params.indexPatternTitle;
|
|
const payload = request.payload;
|
|
return getOverallStats(
|
|
callWithRequest,
|
|
indexPatternTitle,
|
|
payload.query,
|
|
payload.aggregatableFields,
|
|
payload.nonAggregatableFields,
|
|
payload.samplerShardSize,
|
|
payload.timeFieldName,
|
|
payload.earliest,
|
|
payload.latest)
|
|
.catch(resp => wrapError(resp));
|
|
},
|
|
config: {
|
|
...commonRouteConfig
|
|
}
|
|
});
|
|
|
|
}
|