mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
parent
83c878561a
commit
b04c2dc6c9
8 changed files with 34 additions and 41 deletions
|
@ -726,7 +726,7 @@ function discoverController(
|
|||
});
|
||||
|
||||
$scope.searchSource.onRequestStart((searchSource, searchRequest) => {
|
||||
return $scope.vis.onSearchRequestStart(searchSource, searchRequest);
|
||||
return $scope.vis.getAggConfig().onSearchRequestStart(searchSource, searchRequest);
|
||||
});
|
||||
|
||||
$scope.searchSource.aggs(function () {
|
||||
|
|
|
@ -185,7 +185,7 @@ export function CoordinateMapsVisualizationProvider(Notifier, Private) {
|
|||
async getGeohashBounds() {
|
||||
const agg = this._getGeoHashAgg();
|
||||
if (agg) {
|
||||
const searchSource = this.vis.API.createInheritedSearchSource(this.vis.searchSource);
|
||||
const searchSource = this.vis.searchSource.makeChild();
|
||||
searchSource.size(0);
|
||||
searchSource.aggs(function () {
|
||||
const geoBoundsAgg = new AggConfig(agg.vis, {
|
||||
|
|
|
@ -277,8 +277,8 @@ export function SearchSourceProvider(Promise, Private, config) {
|
|||
return clone;
|
||||
}
|
||||
|
||||
makeChild() {
|
||||
return new SearchSource().inherits(this, { callParentStartHandlers: true });
|
||||
makeChild(params) {
|
||||
return new SearchSource().inherits(this, params);
|
||||
}
|
||||
|
||||
new() {
|
||||
|
|
|
@ -86,6 +86,9 @@ class FieldFormatRegistry extends IndexedArray {
|
|||
*/
|
||||
getInstance = _.memoize(function (formatId) {
|
||||
const FieldFormat = this.byId[formatId];
|
||||
if (!FieldFormat) {
|
||||
throw new Error(`Field Format '${formatId}' not found!`);
|
||||
}
|
||||
return new FieldFormat(null, this.getConfig);
|
||||
});
|
||||
|
||||
|
|
|
@ -208,5 +208,18 @@ AggConfigs.prototype.getResponseAggById = function (id) {
|
|||
if (!reqAgg) return;
|
||||
return _.find(reqAgg.getResponseAggs(), { id: id });
|
||||
};
|
||||
/**
|
||||
* Hook for pre-flight logic, see AggType#onSearchRequestStart()
|
||||
* @param {Courier.SearchSource} searchSource
|
||||
* @param {Courier.SearchRequest} searchRequest
|
||||
* @return {Promise<undefined>}
|
||||
*/
|
||||
AggConfigs.prototype.onSearchRequestStart = function (searchSource, searchRequest) {
|
||||
return Promise.all(
|
||||
this.getRequestAggs().map(agg =>
|
||||
agg.onSearchRequestStart(searchSource, searchRequest)
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
export { AggConfigs };
|
||||
|
|
|
@ -18,17 +18,15 @@
|
|||
*/
|
||||
|
||||
import _ from 'lodash';
|
||||
import { SearchSourceProvider } from '../../courier/data_source/search_source';
|
||||
import { VisRequestHandlersRegistryProvider } from '../../registry/vis_request_handlers';
|
||||
import { calculateObjectHash } from '../lib/calculate_object_hash';
|
||||
import { timefilter } from 'ui/timefilter';
|
||||
import { getRequestInspectorStats, getResponseInspectorStats } from '../../courier/utils/courier_inspector_utils';
|
||||
import { tabifyAggResponse } from '../../agg_response/tabify/tabify';
|
||||
|
||||
import { FormattedData } from '../../inspector/adapters';
|
||||
import { getTime } from '../../timefilter/get_time';
|
||||
|
||||
const CourierRequestHandlerProvider = function (Private, courier) {
|
||||
const SearchSource = Private(SearchSourceProvider);
|
||||
const CourierRequestHandlerProvider = function () {
|
||||
|
||||
/**
|
||||
* This function builds tabular data from the response and attaches it to the
|
||||
|
@ -74,7 +72,7 @@ const CourierRequestHandlerProvider = function (Private, courier) {
|
|||
|
||||
return {
|
||||
name: 'courier',
|
||||
handler: function (vis, { searchSource, timeRange, query, filters, forceFetch }) {
|
||||
handler: function (vis, { searchSource, aggs, timeRange, query, filters, forceFetch }) {
|
||||
|
||||
// Create a new search source that inherits the original search source
|
||||
// but has the propriate timeRange applied via a filter.
|
||||
|
@ -83,8 +81,8 @@ const CourierRequestHandlerProvider = function (Private, courier) {
|
|||
// Using callParentStartHandlers: true we make sure, that the parent searchSource
|
||||
// onSearchRequestStart will be called properly even though we use an inherited
|
||||
// search source.
|
||||
const timeFilterSearchSource = searchSource.makeChild();
|
||||
const requestSearchSource = timeFilterSearchSource.makeChild();
|
||||
const timeFilterSearchSource = searchSource.makeChild({ callParentStartHandlers: true });
|
||||
const requestSearchSource = timeFilterSearchSource.makeChild({ callParentStartHandlers: true });
|
||||
|
||||
// For now we need to mirror the history of the passed search source, since
|
||||
// the spy panel wouldn't work otherwise.
|
||||
|
@ -98,15 +96,15 @@ const CourierRequestHandlerProvider = function (Private, courier) {
|
|||
});
|
||||
|
||||
requestSearchSource.aggs(function () {
|
||||
return vis.getAggConfig().toDsl();
|
||||
return aggs.toDsl();
|
||||
});
|
||||
|
||||
requestSearchSource.onRequestStart((searchSource, searchRequest) => {
|
||||
return vis.onSearchRequestStart(searchSource, searchRequest);
|
||||
return aggs.onSearchRequestStart(searchSource, searchRequest);
|
||||
});
|
||||
|
||||
timeFilterSearchSource.set('filter', () => {
|
||||
return timefilter.createFilter(searchSource.get('index'), timeRange);
|
||||
return getTime(searchSource.get('index'), timeRange);
|
||||
});
|
||||
|
||||
requestSearchSource.set('filter', filters);
|
||||
|
@ -128,7 +126,7 @@ const CourierRequestHandlerProvider = function (Private, courier) {
|
|||
});
|
||||
request.stats(getRequestInspectorStats(requestSearchSource));
|
||||
|
||||
requestSearchSource.onResults().then(resp => {
|
||||
requestSearchSource.fetch().then(resp => {
|
||||
searchSource.lastQuery = queryHash;
|
||||
|
||||
request
|
||||
|
@ -138,10 +136,10 @@ const CourierRequestHandlerProvider = function (Private, courier) {
|
|||
searchSource.rawResponse = resp;
|
||||
return _.cloneDeep(resp);
|
||||
}).then(async resp => {
|
||||
for (const agg of vis.getAggConfig()) {
|
||||
for (const agg of aggs) {
|
||||
if (_.has(agg, 'type.postFlightRequest')) {
|
||||
const nestedSearchSource = new SearchSource().inherits(requestSearchSource);
|
||||
resp = await agg.type.postFlightRequest(resp, vis.aggs, agg, nestedSearchSource);
|
||||
const nestedSearchSource = requestSearchSource.makeChild();
|
||||
resp = await agg.type.postFlightRequest(resp, aggs, agg, nestedSearchSource);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -159,7 +157,6 @@ const CourierRequestHandlerProvider = function (Private, courier) {
|
|||
request.json(req);
|
||||
});
|
||||
|
||||
courier.fetch();
|
||||
} else {
|
||||
resolve(searchSource.finalResponse);
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@ import { onBrushEvent } from '../utils/brush_event';
|
|||
import { FilterBarQueryFilterProvider } from '../filter_bar/query_filter';
|
||||
import { FilterBarClickHandlerProvider } from '../filter_bar/filter_bar_click_handler';
|
||||
import { updateVisualizationConfig } from './vis_update';
|
||||
import { queryManagerFactory } from '../query_manager';
|
||||
import { SearchSourceProvider } from '../courier/data_source/search_source';
|
||||
import { SavedObjectsClientProvider } from '../saved_objects';
|
||||
import { timefilter } from 'ui/timefilter';
|
||||
|
@ -56,7 +55,7 @@ const getTerms = (table, columnIndex, rowIndex) => {
|
|||
}))];
|
||||
};
|
||||
|
||||
export function VisProvider(Private, Promise, indexPatterns, getAppState) {
|
||||
export function VisProvider(Private, indexPatterns, getAppState) {
|
||||
const visTypes = Private(VisTypesRegistryProvider);
|
||||
const queryFilter = Private(FilterBarQueryFilterProvider);
|
||||
const filterBarClickHandler = Private(FilterBarClickHandlerProvider);
|
||||
|
@ -88,7 +87,6 @@ export function VisProvider(Private, Promise, indexPatterns, getAppState) {
|
|||
indexPatterns: indexPatterns,
|
||||
timeFilter: timefilter,
|
||||
queryFilter: queryFilter,
|
||||
queryManager: queryManagerFactory(getAppState),
|
||||
events: {
|
||||
// the filter method will be removed in the near feature
|
||||
// you should rather use addFilter method below
|
||||
|
@ -111,12 +109,6 @@ export function VisProvider(Private, Promise, indexPatterns, getAppState) {
|
|||
onBrushEvent(event, getAppState());
|
||||
}
|
||||
},
|
||||
createInheritedSearchSource: (parentSearchSource) => {
|
||||
if (!parentSearchSource) {
|
||||
throw new Error('Unable to inherit search source, visualize saved object does not have search source.');
|
||||
}
|
||||
return new SearchSource().inherits(parentSearchSource);
|
||||
},
|
||||
inspectorAdapters: this._getActiveInspectorAdapters(),
|
||||
};
|
||||
}
|
||||
|
@ -247,19 +239,6 @@ export function VisProvider(Private, Promise, indexPatterns, getAppState) {
|
|||
return this.getStateInternal(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook for pre-flight logic, see AggType#onSearchRequestStart()
|
||||
* @param {Courier.SearchSource} searchSource
|
||||
* @param {Courier.SearchRequest} searchRequest
|
||||
* @return {Promise<undefined>}
|
||||
*/
|
||||
onSearchRequestStart(searchSource, searchRequest) {
|
||||
return Promise.map(
|
||||
this.aggs.getRequestAggs(),
|
||||
agg => agg.onSearchRequestStart(searchSource, searchRequest)
|
||||
);
|
||||
}
|
||||
|
||||
isHierarchical() {
|
||||
if (_.isFunction(this.type.hierarchicalData)) {
|
||||
return !!this.type.hierarchicalData(this);
|
||||
|
|
|
@ -99,6 +99,7 @@ uiModules
|
|||
uiState: $scope.uiState,
|
||||
queryFilter: queryFilter,
|
||||
searchSource: $scope.savedObj.searchSource,
|
||||
aggs: $scope.vis.getAggConfig(),
|
||||
timeRange: $scope.timeRange,
|
||||
filters: $scope.filters,
|
||||
query: $scope.query,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue