From 01ca3cc74e731eb77a552c9026b6cc010c41ef8b Mon Sep 17 00:00:00 2001 From: Matt Bargar Date: Tue, 14 Jan 2020 15:29:09 -0500 Subject: [PATCH 1/4] Revert "Flag nested fields as non-aggregatable (#51774)" This reverts commit c7046a08 --- .../lib/field_capabilities/field_caps_response.test.js | 7 ------- .../fetcher/lib/field_capabilities/field_caps_response.ts | 8 -------- .../index_patterns/fields_for_wildcard_route/response.js | 4 ++-- 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/src/plugins/data/server/index_patterns/fetcher/lib/field_capabilities/field_caps_response.test.js b/src/plugins/data/server/index_patterns/fetcher/lib/field_capabilities/field_caps_response.test.js index 0d787fa56b400..8ddd18c2c67f4 100644 --- a/src/plugins/data/server/index_patterns/fetcher/lib/field_capabilities/field_caps_response.test.js +++ b/src/plugins/data/server/index_patterns/fetcher/lib/field_capabilities/field_caps_response.test.js @@ -143,13 +143,6 @@ describe('index_patterns/field_capabilities/field_caps_response', () => { expect(child).toHaveProperty('subType', { nested: { path: 'nested_object_parent' } }); }); - it('returns nested sub-fields as non-aggregatable', () => { - const fields = readFieldCapsResponse(esResponse); - // Normally a keyword field would be aggregatable, but the fact that it is nested overrides that - const child = fields.find(f => f.name === 'nested_object_parent.child.keyword'); - expect(child).toHaveProperty('aggregatable', false); - }); - it('handles fields that are both nested and multi', () => { const fields = readFieldCapsResponse(esResponse); const child = fields.find(f => f.name === 'nested_object_parent.child.keyword'); diff --git a/src/plugins/data/server/index_patterns/fetcher/lib/field_capabilities/field_caps_response.ts b/src/plugins/data/server/index_patterns/fetcher/lib/field_capabilities/field_caps_response.ts index 2215bd8a95a1d..06eb30db0b24b 100644 --- a/src/plugins/data/server/index_patterns/fetcher/lib/field_capabilities/field_caps_response.ts +++ b/src/plugins/data/server/index_patterns/fetcher/lib/field_capabilities/field_caps_response.ts @@ -182,14 +182,6 @@ export function readFieldCapsResponse(fieldCapsResponse: FieldCapsResponse): Fie if (Object.keys(subType).length > 0) { field.subType = subType; - - // We don't support aggregating on nested fields, trying to do so in the UI will return - // blank results. For now we will stop showing nested fields as an option for aggregation. - // Once we add support for nested fields this condition should be removed and old index - // patterns should be migrated. - if (field.subType.nested) { - field.aggregatable = false; - } } } }); diff --git a/test/api_integration/apis/index_patterns/fields_for_wildcard_route/response.js b/test/api_integration/apis/index_patterns/fields_for_wildcard_route/response.js index 25a533d39dd81..c4c71abdae125 100644 --- a/test/api_integration/apis/index_patterns/fields_for_wildcard_route/response.js +++ b/test/api_integration/apis/index_patterns/fields_for_wildcard_route/response.js @@ -72,7 +72,7 @@ export default function({ getService }) { readFromDocValues: true, }, { - aggregatable: false, + aggregatable: true, esTypes: ['keyword'], name: 'nestedField.child', readFromDocValues: true, @@ -154,7 +154,7 @@ export default function({ getService }) { readFromDocValues: true, }, { - aggregatable: false, + aggregatable: true, esTypes: ['keyword'], name: 'nestedField.child', readFromDocValues: true, From 7044931485a051ea2f5b11faba2d02907519678a Mon Sep 17 00:00:00 2001 From: Matt Bargar Date: Tue, 14 Jan 2020 16:13:29 -0500 Subject: [PATCH 2/4] Filter out nested fields at the agg param level --- src/legacy/ui/public/agg_types/param_types/field.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/legacy/ui/public/agg_types/param_types/field.ts b/src/legacy/ui/public/agg_types/param_types/field.ts index 0ca60267becec..a0fa6ad6e3189 100644 --- a/src/legacy/ui/public/agg_types/param_types/field.ts +++ b/src/legacy/ui/public/agg_types/param_types/field.ts @@ -115,7 +115,10 @@ export class FieldParamType extends BaseParamType { const filteredFields = fields.filter((field: Field) => { const { onlyAggregatable, scriptable, filterFieldTypes } = this; - if ((onlyAggregatable && !field.aggregatable) || (!scriptable && field.scripted)) { + if ( + (onlyAggregatable && (!field.aggregatable || field.subType?.nested)) || + (!scriptable && field.scripted) + ) { return false; } From afcaa348f2e34f5fd00c262ab78dd81bb0e0227d Mon Sep 17 00:00:00 2001 From: Tim Roes Date: Wed, 15 Jan 2020 12:11:31 +0100 Subject: [PATCH 3/4] Forbid nested fields in TSVB --- .../core_plugins/vis_type_timeseries/server/lib/get_fields.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/get_fields.js b/src/legacy/core_plugins/vis_type_timeseries/server/lib/get_fields.js index c16452ab4b895..c04045fc61bb2 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/server/lib/get_fields.js +++ b/src/legacy/core_plugins/vis_type_timeseries/server/lib/get_fields.js @@ -30,7 +30,7 @@ export async function getFields(req) { const fields = ( await searchStrategy.getFieldsForWildcard(req, indexPatternString, capabilities) - ).filter(field => field.aggregatable); + ).filter(field => field.aggregatable && !field.subType?.nested); return uniq(fields, field => field.name); } From d7a99259476a85008967f68ba0f0c81ab25781ec Mon Sep 17 00:00:00 2001 From: Matt Bargar Date: Wed, 15 Jan 2020 17:33:17 -0500 Subject: [PATCH 4/4] Revert "Forbid nested fields in TSVB" This reverts commit afcaa348 --- .../core_plugins/vis_type_timeseries/server/lib/get_fields.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/get_fields.js b/src/legacy/core_plugins/vis_type_timeseries/server/lib/get_fields.js index c04045fc61bb2..c16452ab4b895 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/server/lib/get_fields.js +++ b/src/legacy/core_plugins/vis_type_timeseries/server/lib/get_fields.js @@ -30,7 +30,7 @@ export async function getFields(req) { const fields = ( await searchStrategy.getFieldsForWildcard(req, indexPatternString, capabilities) - ).filter(field => field.aggregatable && !field.subType?.nested); + ).filter(field => field.aggregatable); return uniq(fields, field => field.name); }