Skip to content

Commit

Permalink
[Maps] increase DEFAULT_MAX_BUCKETS_LIMIT to 65535 (#70313) (#71781)
Browse files Browse the repository at this point in the history
Co-authored-by: Elastic Machine <[email protected]>

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
nreese and elasticmachine authored Jul 15, 2020
1 parent 510a684 commit 2491f28
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion x-pack/plugins/maps/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const DECIMAL_DEGREES_PRECISION = 5; // meters precision
export const ZOOM_PRECISION = 2;
export const DEFAULT_MAX_RESULT_WINDOW = 10000;
export const DEFAULT_MAX_INNER_RESULT_WINDOW = 100;
export const DEFAULT_MAX_BUCKETS_LIMIT = 10000;
export const DEFAULT_MAX_BUCKETS_LIMIT = 65535;

export const FEATURE_ID_PROPERTY_NAME = '__kbn__feature_id__';
export const FEATURE_VISIBLE_PROPERTY_NAME = '__kbn_isvisibleduetojoin__';
Expand Down
6 changes: 4 additions & 2 deletions x-pack/plugins/maps/public/classes/fields/es_agg_field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import { TopTermPercentageField } from './top_term_percentage_field';
import { ITooltipProperty, TooltipProperty } from '../tooltips/tooltip_property';
import { ESAggTooltipProperty } from '../tooltips/es_agg_tooltip_property';

const TERMS_AGG_SHARD_SIZE = 5;

export interface IESAggField extends IField {
getValueAggDsl(indexPattern: IndexPattern): unknown | null;
getBucketCount(): number;
Expand Down Expand Up @@ -100,15 +102,15 @@ export class ESAggField implements IESAggField {

const field = getField(indexPattern, this.getRootName());
const aggType = this.getAggType();
const aggBody = aggType === AGG_TYPE.TERMS ? { size: 1, shard_size: 1 } : {};
const aggBody = aggType === AGG_TYPE.TERMS ? { size: 1, shard_size: TERMS_AGG_SHARD_SIZE } : {};
return {
[aggType]: addFieldToDSL(aggBody, field),
};
}

getBucketCount(): number {
// terms aggregation increases the overall number of buckets per split bucket
return this.getAggType() === AGG_TYPE.TERMS ? 1 : 0;
return this.getAggType() === AGG_TYPE.TERMS ? TERMS_AGG_SHARD_SIZE : 0;
}

supportsFieldMeta(): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ export class ESGeoGridSource extends AbstractESAggSource {
bounds: makeESBbox(bufferedExtent),
field: this._descriptor.geoField,
precision,
size: DEFAULT_MAX_BUCKETS_LIMIT,
},
},
},
Expand Down Expand Up @@ -245,6 +246,8 @@ export class ESGeoGridSource extends AbstractESAggSource {
bounds: makeESBbox(bufferedExtent),
field: this._descriptor.geoField,
precision,
size: DEFAULT_MAX_BUCKETS_LIMIT,
shard_size: DEFAULT_MAX_BUCKETS_LIMIT,
},
aggs: {
gridCentroid: {
Expand Down
5 changes: 3 additions & 2 deletions x-pack/plugins/maps/public/elasticsearch_geo_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,9 @@ export function getBoundingBoxGeometry(geometry) {
export function formatEnvelopeAsPolygon({ maxLat, maxLon, minLat, minLon }) {
// GeoJSON mandates that the outer polygon must be counterclockwise to avoid ambiguous polygons
// when the shape crosses the dateline
const left = minLon;
const right = maxLon;
const lonDelta = maxLon - minLon;
const left = lonDelta > 360 ? -180 : minLon;
const right = lonDelta > 360 ? 180 : maxLon;
const top = clampToLatBounds(maxLat);
const bottom = clampToLatBounds(minLat);
const topLeft = [left, top];
Expand Down
12 changes: 6 additions & 6 deletions x-pack/plugins/maps/public/elasticsearch_geo_utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ describe('createExtentFilter', () => {
});
});

it('should not clamp longitudes to -180 to 180', () => {
it('should clamp longitudes to -180 to 180 when lonitude wraps globe', () => {
const mapExtent = {
maxLat: 39,
maxLon: 209,
Expand All @@ -436,11 +436,11 @@ describe('createExtentFilter', () => {
shape: {
coordinates: [
[
[-191, 39],
[-191, 35],
[209, 35],
[209, 39],
[-191, 39],
[-180, 39],
[-180, 35],
[180, 35],
[180, 39],
[-180, 39],
],
],
type: 'Polygon',
Expand Down

0 comments on commit 2491f28

Please sign in to comment.