diff --git a/x-pack/plugins/maps/public/classes/sources/es_search_source/__snapshots__/scaling_form.test.tsx.snap b/x-pack/plugins/maps/public/classes/sources/es_search_source/__snapshots__/scaling_form.test.tsx.snap
index dd62be11c679..120ff2e7adde 100644
--- a/x-pack/plugins/maps/public/classes/sources/es_search_source/__snapshots__/scaling_form.test.tsx.snap
+++ b/x-pack/plugins/maps/public/classes/sources/es_search_source/__snapshots__/scaling_form.test.tsx.snap
@@ -67,84 +67,6 @@ exports[`scaling form should disable clusters option when clustering is not supp
>
-
-
-
-
-
-
-
-`;
-
-exports[`scaling form should disable mvt option when mvt is not supported 1`] = `
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -162,8 +159,6 @@ export class CreateSourceEditor extends Component {
this.state.indexPattern,
this.state.geoFieldName
)}
- supportsMvt={mvtSupported}
- mvtDisabledReason={mvtSupported ? null : getMvtDisabledReason()}
clusteringDisabledReason={
this.state.indexPattern
? getGeoTileAggNotSupportedReason(
diff --git a/x-pack/plugins/maps/public/classes/sources/es_search_source/es_search_source.js b/x-pack/plugins/maps/public/classes/sources/es_search_source/es_search_source.js
index edcafae54d54..da75dfd83d80 100644
--- a/x-pack/plugins/maps/public/classes/sources/es_search_source/es_search_source.js
+++ b/x-pack/plugins/maps/public/classes/sources/es_search_source/es_search_source.js
@@ -614,7 +614,9 @@ export class ESSearchSource extends AbstractESSource {
`/${GIS_API_PATH}/${MVT_GETTILE_API_PATH}`
);
- const urlTemplate = `${mvtUrlServicePath}?x={x}&y={y}&z={z}&geometryFieldName=${this._descriptor.geoField}&index=${indexPattern.title}&requestBody=${risonDsl}`;
+ const geoField = await this._getGeoField();
+
+ const urlTemplate = `${mvtUrlServicePath}?x={x}&y={y}&z={z}&geometryFieldName=${this._descriptor.geoField}&index=${indexPattern.title}&requestBody=${risonDsl}&geoFieldType=${geoField.type}`;
return {
layerName: this.getLayerName(),
minSourceZoom: this.getMinZoom(),
diff --git a/x-pack/plugins/maps/public/classes/sources/es_search_source/es_search_source.test.ts b/x-pack/plugins/maps/public/classes/sources/es_search_source/es_search_source.test.ts
index 0bc9bba7816c..9c1cda4088dc 100644
--- a/x-pack/plugins/maps/public/classes/sources/es_search_source/es_search_source.test.ts
+++ b/x-pack/plugins/maps/public/classes/sources/es_search_source/es_search_source.test.ts
@@ -110,7 +110,7 @@ describe('ESSearchSource', () => {
);
const urlTemplateWithMeta = await esSearchSource.getUrlTemplateWithMeta(searchFilters);
expect(urlTemplateWithMeta.urlTemplate).toBe(
- `rootdir/api/maps/mvt/getTile;?x={x}&y={y}&z={z}&geometryFieldName=bar&index=foobar-title-*&requestBody=(foobar:ES_DSL_PLACEHOLDER,params:('0':('0':index,'1':(fields:(),title:'foobar-title-*')),'1':('0':size,'1':1000),'2':('0':filter,'1':!()),'3':('0':query),'4':('0':index,'1':(fields:(),title:'foobar-title-*')),'5':('0':query,'1':(language:KQL,query:'tooltipField: foobar',queryLastTriggeredAt:'2019-04-25T20:53:22.331Z')),'6':('0':fields,'1':!(tooltipField,styleField)),'7':('0':source,'1':!(tooltipField,styleField))))`
+ `rootdir/api/maps/mvt/getTile;?x={x}&y={y}&z={z}&geometryFieldName=bar&index=foobar-title-*&requestBody=(foobar:ES_DSL_PLACEHOLDER,params:('0':('0':index,'1':(fields:(),title:'foobar-title-*')),'1':('0':size,'1':1000),'2':('0':filter,'1':!()),'3':('0':query),'4':('0':index,'1':(fields:(),title:'foobar-title-*')),'5':('0':query,'1':(language:KQL,query:'tooltipField: foobar',queryLastTriggeredAt:'2019-04-25T20:53:22.331Z')),'6':('0':fields,'1':!(tooltipField,styleField)),'7':('0':source,'1':!(tooltipField,styleField))))&geoFieldType=geo_shape`
);
});
});
diff --git a/x-pack/plugins/maps/public/classes/sources/es_search_source/scaling_form.test.tsx b/x-pack/plugins/maps/public/classes/sources/es_search_source/scaling_form.test.tsx
index f57335db14c6..867e56f3e24b 100644
--- a/x-pack/plugins/maps/public/classes/sources/es_search_source/scaling_form.test.tsx
+++ b/x-pack/plugins/maps/public/classes/sources/es_search_source/scaling_form.test.tsx
@@ -27,8 +27,6 @@ const defaultProps = {
termFields: [],
topHitsSplitField: null,
topHitsSize: 1,
- supportsMvt: true,
- mvtDisabledReason: null,
};
describe('scaling form', () => {
@@ -57,16 +55,4 @@ describe('scaling form', () => {
expect(component).toMatchSnapshot();
});
-
- test('should disable mvt option when mvt is not supported', async () => {
- const component = shallow(
-
- );
-
- expect(component).toMatchSnapshot();
- });
});
diff --git a/x-pack/plugins/maps/public/classes/sources/es_search_source/scaling_form.tsx b/x-pack/plugins/maps/public/classes/sources/es_search_source/scaling_form.tsx
index cc2d4d059a3a..370c3f8923ea 100644
--- a/x-pack/plugins/maps/public/classes/sources/es_search_source/scaling_form.tsx
+++ b/x-pack/plugins/maps/public/classes/sources/es_search_source/scaling_form.tsx
@@ -39,9 +39,7 @@ interface Props {
onChange: (args: OnSourceChangeArgs) => void;
scalingType: SCALING_TYPES;
supportsClustering: boolean;
- supportsMvt: boolean;
clusteringDisabledReason?: string | null;
- mvtDisabledReason?: string | null;
termFields: IFieldType[];
topHitsSplitField: string | null;
topHitsSize: number;
@@ -197,7 +195,6 @@ export class ScalingForm extends Component {
label={labelText}
checked={this.props.scalingType === SCALING_TYPES.MVT}
onChange={() => this._onScalingTypeChange(SCALING_TYPES.MVT)}
- disabled={!this.props.supportsMvt}
/>
);
@@ -211,11 +208,7 @@ export class ScalingForm extends Component {
>
);
- return !this.props.supportsMvt ? (
-
- {mvtRadio}
-
- ) : (
+ return (
{mvtRadio}
diff --git a/x-pack/plugins/maps/public/classes/sources/es_search_source/update_source_editor.js b/x-pack/plugins/maps/public/classes/sources/es_search_source/update_source_editor.js
index c123c307c489..735510102e25 100644
--- a/x-pack/plugins/maps/public/classes/sources/es_search_source/update_source_editor.js
+++ b/x-pack/plugins/maps/public/classes/sources/es_search_source/update_source_editor.js
@@ -17,8 +17,6 @@ import {
getTermsFields,
getSourceFields,
supportsGeoTileAgg,
- supportsMvt,
- getMvtDisabledReason,
} from '../../../index_pattern_util';
import { SORT_ORDER } from '../../../../common/constants';
import { ESDocField } from '../../fields/es_doc_field';
@@ -44,7 +42,6 @@ export class UpdateSourceEditor extends Component {
termFields: null,
sortFields: null,
supportsClustering: false,
- supportsMvt: false,
mvtDisabledReason: null,
clusteringDisabledReason: null,
};
@@ -99,12 +96,10 @@ export class UpdateSourceEditor extends Component {
});
});
- const mvtSupported = supportsMvt(indexPattern, geoField.name);
this.setState({
supportsClustering: supportsGeoTileAgg(geoField),
- supportsMvt: mvtSupported,
clusteringDisabledReason: getGeoTileAggNotSupportedReason(geoField),
- mvtDisabledReason: mvtSupported ? null : getMvtDisabledReason(),
+ mvtDisabledReason: null,
sourceFields: sourceFields,
termFields: getTermsFields(indexPattern.fields), //todo change term fields to use fields
sortFields: indexPattern.fields.filter(
@@ -215,9 +210,7 @@ export class UpdateSourceEditor extends Component {
onChange={this.props.onChange}
scalingType={this.props.scalingType}
supportsClustering={this.state.supportsClustering}
- supportsMvt={this.state.supportsMvt}
clusteringDisabledReason={this.state.clusteringDisabledReason}
- mvtDisabledReason={this.state.mvtDisabledReason}
termFields={this.state.termFields}
topHitsSplitField={this.props.topHitsSplitField}
topHitsSize={this.props.topHitsSize}
diff --git a/x-pack/plugins/maps/public/index_pattern_util.ts b/x-pack/plugins/maps/public/index_pattern_util.ts
index 7af1571a0bc5..68fd224dcbb4 100644
--- a/x-pack/plugins/maps/public/index_pattern_util.ts
+++ b/x-pack/plugins/maps/public/index_pattern_util.ts
@@ -82,17 +82,6 @@ export function supportsGeoTileAgg(field?: IFieldType): boolean {
);
}
-export function supportsMvt(indexPattern: IndexPattern, geoFieldName: string): boolean {
- const field = indexPattern.fields.getByName(geoFieldName);
- return !!field && field.type === ES_GEO_FIELD_TYPE.GEO_SHAPE;
-}
-
-export function getMvtDisabledReason() {
- return i18n.translate('xpack.maps.mbt.disabled', {
- defaultMessage: 'Display as vector tiles is only supported for geo_shape field-types.',
- });
-}
-// Returns filtered fields list containing only fields that exist in _source.
export function getSourceFields(fields: IFieldType[]): IFieldType[] {
return fields.filter((field) => {
// Multi fields are not stored in _source and only exist in index.
diff --git a/x-pack/plugins/maps/server/mvt/get_tile.test.ts b/x-pack/plugins/maps/server/mvt/get_tile.test.ts
index 76c1741ab2ad..1e00fd27e3d1 100644
--- a/x-pack/plugins/maps/server/mvt/get_tile.test.ts
+++ b/x-pack/plugins/maps/server/mvt/get_tile.test.ts
@@ -50,6 +50,7 @@ describe('getTile', () => {
info: () => {},
} as unknown) as Logger,
callElasticsearch: mockCallElasticsearch,
+ geoFieldType: ES_GEO_FIELD_TYPE.GEO_SHAPE,
});
compareTiles('./__tests__/pbf/0_0_0_docs.pbf', tile);
diff --git a/x-pack/plugins/maps/server/mvt/get_tile.ts b/x-pack/plugins/maps/server/mvt/get_tile.ts
index dd88be7f80c2..cc87f3b65522 100644
--- a/x-pack/plugins/maps/server/mvt/get_tile.ts
+++ b/x-pack/plugins/maps/server/mvt/get_tile.ts
@@ -21,9 +21,8 @@ import {
SUPER_FINE_ZOOM_DELTA,
} from '../../common/constants';
-import { hitsToGeoJson } from '../../common/elasticsearch_util';
+import { convertRegularRespToGeoJson, hitsToGeoJson } from '../../common/elasticsearch_util';
import { flattenHit } from './util';
-import { convertRegularRespToGeoJson } from '../../common/elasticsearch_util';
import { ESBounds, tile2lat, tile2long, tileToESBbox } from '../../common/geo_tile_utils';
export async function getGridTile({
@@ -107,6 +106,7 @@ export async function getTile({
y,
z,
requestBody = {},
+ geoFieldType,
}: {
x: number;
y: number;
@@ -116,6 +116,7 @@ export async function getTile({
callElasticsearch: (type: string, ...args: any[]) => Promise;
logger: Logger;
requestBody: any;
+ geoFieldType: ES_GEO_FIELD_TYPE;
}): Promise {
const geojsonBbox = tileToGeoJsonPolygon(x, y, z);
@@ -181,7 +182,6 @@ export async function getTile({
},
];
} else {
- // Perform actual search
result = await callElasticsearch('search', esSearchQuery);
// Todo: pass in epochMillies-fields
@@ -192,7 +192,7 @@ export async function getTile({
return flattenHit(geometryFieldName, hit);
},
geometryFieldName,
- ES_GEO_FIELD_TYPE.GEO_SHAPE,
+ geoFieldType,
[]
);
diff --git a/x-pack/plugins/maps/server/mvt/mvt_routes.ts b/x-pack/plugins/maps/server/mvt/mvt_routes.ts
index 266a240b5301..fc298f73b04a 100644
--- a/x-pack/plugins/maps/server/mvt/mvt_routes.ts
+++ b/x-pack/plugins/maps/server/mvt/mvt_routes.ts
@@ -36,6 +36,7 @@ export function initMVTRoutes({ router, logger }: { logger: Logger; router: IRou
geometryFieldName: schema.string(),
requestBody: schema.string(),
index: schema.string(),
+ geoFieldType: schema.string(),
}),
},
},
@@ -56,6 +57,7 @@ export function initMVTRoutes({ router, logger }: { logger: Logger; router: IRou
z: query.z as number,
index: query.index as string,
requestBody: requestBodyDSL as any,
+ geoFieldType: query.geoFieldType as ES_GEO_FIELD_TYPE,
});
return sendResponse(response, tile);
diff --git a/x-pack/test/api_integration/apis/maps/get_tile.js b/x-pack/test/api_integration/apis/maps/get_tile.js
index 7219fc858e05..9dd0698b6c6e 100644
--- a/x-pack/test/api_integration/apis/maps/get_tile.js
+++ b/x-pack/test/api_integration/apis/maps/get_tile.js
@@ -11,7 +11,7 @@ export default function ({ getService }) {
it('should validate params', async () => {
await supertest
.get(
- `/api/maps/mvt/getTile?x=15&y=11&z=5&geometryFieldName=coordinates&index=logstash*&requestBody=(_source:(includes:!(coordinates)),docvalue_fields:!(),query:(bool:(filter:!((match_all:())),must:!(),must_not:!(),should:!())),script_fields:(),size:10000,stored_fields:!(coordinates))`
+ `/api/maps/mvt/getTile?x=15&y=11&z=5&geometryFieldName=coordinates&index=logstash*&requestBody=(_source:(includes:!(coordinates)),docvalue_fields:!(),query:(bool:(filter:!((match_all:())),must:!(),must_not:!(),should:!())),script_fields:(),size:10000,stored_fields:!(coordinates))&geoFieldType=geo_point`
)
.set('kbn-xsrf', 'kibana')
.expect(200);
diff --git a/x-pack/test/functional/apps/maps/mvt_scaling.js b/x-pack/test/functional/apps/maps/mvt_scaling.js
index 46ae2c0b9463..b5c9ddcbd5e1 100644
--- a/x-pack/test/functional/apps/maps/mvt_scaling.js
+++ b/x-pack/test/functional/apps/maps/mvt_scaling.js
@@ -29,7 +29,7 @@ export default function ({ getPageObjects, getService }) {
//Source should be correct
expect(mapboxStyle.sources[VECTOR_SOURCE_ID].tiles[0]).to.equal(
- '/api/maps/mvt/getTile?x={x}&y={y}&z={z}&geometryFieldName=geometry&index=geo_shapes*&requestBody=(_source:(includes:!(geometry,prop1)),docvalue_fields:!(prop1),query:(bool:(filter:!((match_all:())),must:!(),must_not:!(),should:!())),script_fields:(),size:10000,stored_fields:!(geometry,prop1))'
+ '/api/maps/mvt/getTile?x={x}&y={y}&z={z}&geometryFieldName=geometry&index=geo_shapes*&requestBody=(_source:(includes:!(geometry,prop1)),docvalue_fields:!(prop1),query:(bool:(filter:!((match_all:())),must:!(),must_not:!(),should:!())),script_fields:(),size:10000,stored_fields:!(geometry,prop1))&geoFieldType=geo_shape'
);
//Should correctly load meta for style-rule (sigma is set to 1, opacity to 1)