From d3ea7756195331d02c228937a99951fc7ca2ab4a Mon Sep 17 00:00:00 2001 From: Thomas Neirynck Date: Tue, 5 May 2020 09:23:42 -0400 Subject: [PATCH] [Maps] [Telemetry] Track geo_point and geo_shape index patterns separately (#65195) --- x-pack/legacy/plugins/maps/mappings.json | 6 +++++ .../maps_telemetry/maps_telemetry.test.js | 6 ++++- .../server/maps_telemetry/maps_telemetry.ts | 26 ++++++++++++++++--- .../sample_index_pattern_saved_objects.json | 14 ++++++++++ 4 files changed, 47 insertions(+), 5 deletions(-) diff --git a/x-pack/legacy/plugins/maps/mappings.json b/x-pack/legacy/plugins/maps/mappings.json index 5e2e8c2c7e6e5c..c939d096d7849f 100644 --- a/x-pack/legacy/plugins/maps/mappings.json +++ b/x-pack/legacy/plugins/maps/mappings.json @@ -36,6 +36,12 @@ "indexPatternsWithGeoFieldCount": { "type": "long" }, + "indexPatternsWithGeoPointFieldCount": { + "type": "long" + }, + "indexPatternsWithGeoShapeFieldCount": { + "type": "long" + }, "mapsTotalCount": { "type": "long" }, diff --git a/x-pack/legacy/plugins/maps/server/maps_telemetry/maps_telemetry.test.js b/x-pack/legacy/plugins/maps/server/maps_telemetry/maps_telemetry.test.js index 981a7f46e7c004..6131ff45c4a0f6 100644 --- a/x-pack/legacy/plugins/maps/server/maps_telemetry/maps_telemetry.test.js +++ b/x-pack/legacy/plugins/maps/server/maps_telemetry/maps_telemetry.test.js @@ -20,6 +20,8 @@ describe('buildMapsTelemetry', () => { expect(result).toMatchObject({ indexPatternsWithGeoFieldCount: 0, + indexPatternsWithGeoPointFieldCount: 0, + indexPatternsWithGeoShapeFieldCount: 0, attributesPerMap: { dataSourcesCount: { avg: 0, @@ -45,7 +47,9 @@ describe('buildMapsTelemetry', () => { const result = buildMapsTelemetry({ mapSavedObjects, indexPatternSavedObjects, settings }); expect(result).toMatchObject({ - indexPatternsWithGeoFieldCount: 2, + indexPatternsWithGeoFieldCount: 3, + indexPatternsWithGeoPointFieldCount: 2, + indexPatternsWithGeoShapeFieldCount: 1, attributesPerMap: { dataSourcesCount: { avg: 2.6666666666666665, diff --git a/x-pack/legacy/plugins/maps/server/maps_telemetry/maps_telemetry.ts b/x-pack/legacy/plugins/maps/server/maps_telemetry/maps_telemetry.ts index 4610baabad3fe5..fe22c114cd921c 100644 --- a/x-pack/legacy/plugins/maps/server/maps_telemetry/maps_telemetry.ts +++ b/x-pack/legacy/plugins/maps/server/maps_telemetry/maps_telemetry.ts @@ -61,13 +61,27 @@ function getIndexPatternsWithGeoFieldCount(indexPatterns: IIndexPattern[]) { ? JSON.parse(indexPattern.attributes.fields) : [] ); + const fieldListsWithGeoFields = fieldLists.filter(fields => fields.some( (field: IFieldType) => field.type === ES_GEO_FIELD_TYPE.GEO_POINT || field.type === ES_GEO_FIELD_TYPE.GEO_SHAPE ) ); - return fieldListsWithGeoFields.length; + + const fieldListsWithGeoPointFields = fieldLists.filter(fields => + fields.some((field: IFieldType) => field.type === ES_GEO_FIELD_TYPE.GEO_POINT) + ); + + const fieldListsWithGeoShapeFields = fieldLists.filter(fields => + fields.some((field: IFieldType) => field.type === ES_GEO_FIELD_TYPE.GEO_SHAPE) + ); + + return { + indexPatternsWithGeoFieldCount: fieldListsWithGeoFields.length, + indexPatternsWithGeoPointFieldCount: fieldListsWithGeoPointFields.length, + indexPatternsWithGeoShapeFieldCount: fieldListsWithGeoShapeFields.length, + }; } export function buildMapsTelemetry({ @@ -110,12 +124,16 @@ export function buildMapsTelemetry({ const dataSourcesCountSum = _.sum(dataSourcesCount); const layersCountSum = _.sum(layersCount); - const indexPatternsWithGeoFieldCount = getIndexPatternsWithGeoFieldCount( - indexPatternSavedObjects - ); + const { + indexPatternsWithGeoFieldCount, + indexPatternsWithGeoPointFieldCount, + indexPatternsWithGeoShapeFieldCount, + } = getIndexPatternsWithGeoFieldCount(indexPatternSavedObjects); return { settings, indexPatternsWithGeoFieldCount, + indexPatternsWithGeoPointFieldCount, + indexPatternsWithGeoShapeFieldCount, // Total count of maps mapsTotalCount: mapsCount, // Time of capture diff --git a/x-pack/legacy/plugins/maps/server/maps_telemetry/test_resources/sample_index_pattern_saved_objects.json b/x-pack/legacy/plugins/maps/server/maps_telemetry/test_resources/sample_index_pattern_saved_objects.json index bb30a60f6d69f6..0b36d5ff840162 100644 --- a/x-pack/legacy/plugins/maps/server/maps_telemetry/test_resources/sample_index_pattern_saved_objects.json +++ b/x-pack/legacy/plugins/maps/server/maps_telemetry/test_resources/sample_index_pattern_saved_objects.json @@ -28,6 +28,20 @@ "updated_at": "2019-11-19T20:05:37.607Z", "version": "WzExMSwxXQ==" }, + { + "attributes": { + "fields": "[{\"name\":\"geometry\",\"type\":\"geo_point\",\"esTypes\":[\"geo_point\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true}]", + "title": "indexpattern-with-geopoint2" + }, + "id": "55d572f0-0b07-11ea-9dd2-95afd7ad44d4", + "migrationVersion": { + "index-pattern": "7.6.0" + }, + "references": [], + "type": "index-pattern", + "updated_at": "2019-11-19T20:05:37.607Z", + "version": "WzExMSwxXQ==" + }, { "attributes": { "fields": "[{\"name\":\"assessment_date\",\"type\":\"date\",\"esTypes\":[\"date\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"date_exterior_condition\",\"type\":\"date\",\"esTypes\":[\"date\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"recording_date\",\"type\":\"date\",\"esTypes\":[\"date\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"sale_date\",\"type\":\"date\",\"esTypes\":[\"date\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true}]",