Skip to content

Commit 69c30aa

Browse files
committed
Flag nested fields as non-aggregatable
1 parent 8448961 commit 69c30aa

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

src/plugins/data/server/index_patterns/fetcher/lib/field_capabilities/field_caps_response.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,13 @@ describe('index_patterns/field_capabilities/field_caps_response', () => {
144144
expect(child).toHaveProperty('subType', { nested: { path: 'nested_object_parent' } });
145145
});
146146

147+
it('returns nested sub-fields as non-aggregatable', () => {
148+
const fields = readFieldCapsResponse(esResponse);
149+
// Normally a keyword field would be aggregatable, but the fact that it is nested overrides that
150+
const child = fields.find(f => f.name === 'nested_object_parent.child.keyword');
151+
expect(child).toHaveProperty('aggregatable', false);
152+
});
153+
147154
it('handles fields that are both nested and multi', () => {
148155
const fields = readFieldCapsResponse(esResponse);
149156
const child = fields.find(f => f.name === 'nested_object_parent.child.keyword');

src/plugins/data/server/index_patterns/fetcher/lib/field_capabilities/field_caps_response.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,14 @@ export function readFieldCapsResponse(fieldCapsResponse: FieldCapsResponse): Fie
182182

183183
if (Object.keys(subType).length > 0) {
184184
field.subType = subType;
185+
186+
// We don't support aggregating on nested fields, trying to do so in the UI will return
187+
// blank results. For now we will stop showing nested fields as an option for aggregation.
188+
// Once we add support for nested fields this condition should be removed and old index
189+
// patterns should be migrated.
190+
if (field.subType.nested) {
191+
field.aggregatable = false;
192+
}
185193
}
186194
}
187195
});

0 commit comments

Comments
 (0)