mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Maps] get isClustered from count request instead of source data request (#71528)
* [Maps] get isClustered from count request instead of source data request * better naming * tslint * review feedback
This commit is contained in:
parent
385e4d0a21
commit
301d9cecf6
4 changed files with 11 additions and 15 deletions
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
/* eslint-disable @typescript-eslint/consistent-type-definitions */
|
||||
|
||||
import { RENDER_AS, SORT_ORDER, SCALING_TYPES, SOURCE_TYPES } from '../constants';
|
||||
import { RENDER_AS, SORT_ORDER, SCALING_TYPES } from '../constants';
|
||||
import { MapExtent, MapQuery } from './map_descriptor';
|
||||
import { Filter, TimeRange } from '../../../../../src/plugins/data/common';
|
||||
|
||||
|
@ -26,12 +26,10 @@ type ESSearchSourceSyncMeta = {
|
|||
scalingType: SCALING_TYPES;
|
||||
topHitsSplitField: string;
|
||||
topHitsSize: number;
|
||||
sourceType: SOURCE_TYPES.ES_SEARCH;
|
||||
};
|
||||
|
||||
type ESGeoGridSourceSyncMeta = {
|
||||
requestType: RENDER_AS;
|
||||
sourceType: SOURCE_TYPES.ES_GEO_GRID;
|
||||
};
|
||||
|
||||
export type VectorSourceSyncMeta = ESSearchSourceSyncMeta | ESGeoGridSourceSyncMeta | null;
|
||||
|
|
|
@ -11,7 +11,6 @@ import { getDefaultDynamicProperties } from '../../styles/vector/vector_style_de
|
|||
import { IDynamicStyleProperty } from '../../styles/vector/properties/dynamic_style_property';
|
||||
import { IStyleProperty } from '../../styles/vector/properties/style_property';
|
||||
import {
|
||||
SOURCE_TYPES,
|
||||
COUNT_PROP_LABEL,
|
||||
COUNT_PROP_NAME,
|
||||
LAYER_TYPE,
|
||||
|
@ -41,6 +40,10 @@ import { IVectorSource } from '../../sources/vector_source';
|
|||
|
||||
const ACTIVE_COUNT_DATA_ID = 'ACTIVE_COUNT_DATA_ID';
|
||||
|
||||
interface CountData {
|
||||
isSyncClustered: boolean;
|
||||
}
|
||||
|
||||
function getAggType(dynamicProperty: IDynamicStyleProperty): AGG_TYPE {
|
||||
return dynamicProperty.isOrdinal() ? AGG_TYPE.AVG : AGG_TYPE.TERMS;
|
||||
}
|
||||
|
@ -187,14 +190,10 @@ export class BlendedVectorLayer extends VectorLayer implements IVectorLayer {
|
|||
this._clusterStyle = new VectorStyle(clusterStyleDescriptor, this._clusterSource, this);
|
||||
|
||||
let isClustered = false;
|
||||
const sourceDataRequest = this.getSourceDataRequest();
|
||||
if (sourceDataRequest) {
|
||||
const requestMeta = sourceDataRequest.getMeta();
|
||||
if (
|
||||
requestMeta &&
|
||||
requestMeta.sourceMeta &&
|
||||
requestMeta.sourceMeta.sourceType === SOURCE_TYPES.ES_GEO_GRID
|
||||
) {
|
||||
const countDataRequest = this.getDataRequest(ACTIVE_COUNT_DATA_ID);
|
||||
if (countDataRequest) {
|
||||
const requestData = countDataRequest.getData() as CountData;
|
||||
if (requestData && requestData.isSyncClustered) {
|
||||
isClustered = true;
|
||||
}
|
||||
}
|
||||
|
@ -284,7 +283,8 @@ export class BlendedVectorLayer extends VectorLayer implements IVectorLayer {
|
|||
const resp = await searchSource.fetch();
|
||||
const maxResultWindow = await this._documentSource.getMaxResultWindow();
|
||||
isSyncClustered = resp.hits.total > maxResultWindow;
|
||||
syncContext.stopLoading(dataRequestId, requestToken, { isSyncClustered }, searchFilters);
|
||||
const countData = { isSyncClustered } as CountData;
|
||||
syncContext.stopLoading(dataRequestId, requestToken, countData, searchFilters);
|
||||
} catch (error) {
|
||||
if (!(error instanceof DataRequestAbortError)) {
|
||||
syncContext.onLoadError(dataRequestId, requestToken, error.message);
|
||||
|
|
|
@ -63,7 +63,6 @@ export class ESGeoGridSource extends AbstractESAggSource {
|
|||
getSyncMeta() {
|
||||
return {
|
||||
requestType: this._descriptor.requestType,
|
||||
sourceType: SOURCE_TYPES.ES_GEO_GRID,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -540,7 +540,6 @@ export class ESSearchSource extends AbstractESSource {
|
|||
scalingType: this._descriptor.scalingType,
|
||||
topHitsSplitField: this._descriptor.topHitsSplitField,
|
||||
topHitsSize: this._descriptor.topHitsSize,
|
||||
sourceType: SOURCE_TYPES.ES_SEARCH,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue