Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[data.search.aggs] Use fields instead of _source in top_hits agg #109531

Merged
merged 31 commits into from
Sep 22, 2021
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4000b13
[data.search] Handle warnings inside of headers
lukasolson Jun 29, 2021
1effec0
Merge branch 'master' into search-handle-warnings
lukasolson Jun 30, 2021
1436872
Update docs
lukasolson Jul 1, 2021
158d491
Merge branch 'master' into search-handle-warnings
lukasolson Jul 1, 2021
85b4486
Merge branch 'master' into search-handle-warnings
lukasolson Jul 6, 2021
a98e7c6
Add tests
lukasolson Jul 7, 2021
69e1bc9
Merge branch 'master' into search-handle-warnings
kibanamachine Jul 8, 2021
68f4361
Merge branch 'master' into search-handle-warnings
kibanamachine Jul 13, 2021
9883f46
Merge branch 'master' into search-handle-warnings
lukasolson Jul 26, 2021
898db15
Remove isWarningResponse
lukasolson Jul 26, 2021
73e0eb0
Merge branch 'search-handle-warnings' of github.com:lukasolson/kibana…
lukasolson Jul 26, 2021
2d6ab50
Merge branch 'master' into search-handle-warnings
kibanamachine Aug 2, 2021
671aeed
Merge branch 'master' into search-handle-warnings
lukasolson Aug 2, 2021
033a84d
Merge branch 'master' into search-handle-warnings
kibanamachine Aug 5, 2021
056f6d0
Merge branch 'master' into search-handle-warnings
lukasolson Aug 5, 2021
d386872
Merge branch 'search-handle-warnings' of github.com:lukasolson/kibana…
lukasolson Aug 5, 2021
20dd68a
Merge branch 'master' into search-handle-warnings
kibanamachine Aug 10, 2021
774373c
Merge branch 'master' into search-handle-warnings
kibanamachine Aug 12, 2021
675e584
Merge branch 'master' into search-handle-warnings
kibanamachine Aug 16, 2021
901870a
Merge branch 'search-handle-warnings' of github.com:lukasolson/kibana…
lukasolson Aug 16, 2021
d0db0f3
Merge branch 'master' into search-handle-warnings
lukasolson Aug 16, 2021
7ab5241
Merge remote-tracking branch 'upstream/master'
lukasolson Aug 19, 2021
913d178
Merge remote-tracking branch 'upstream/master'
lukasolson Aug 19, 2021
950ae9f
[data.search.aggs] Use fields instead of _source in top_hits agg
lukasolson Aug 20, 2021
34b0d89
Merge branch 'master' into top-hits-fields
kibanamachine Aug 23, 2021
0b94d40
Merge branch 'master' into top-hits-fields
lukasolson Sep 2, 2021
4fe172c
Merge branch 'master' into top-hits-fields
lukasolson Sep 8, 2021
1f4b1da
Merge remote-tracking branch 'origin/top-hits-fields' into top-hits-f…
lukasolson Sep 8, 2021
99e1f63
Merge branch 'master' into top-hits-fields
lukasolson Sep 10, 2021
9393509
Merge branch 'master' into top-hits-fields
lukasolson Sep 13, 2021
31668e9
Merge branch 'master' into top-hits-fields
lukasolson Sep 22, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/plugins/data/common/search/aggs/metrics/top_hit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,28 +133,28 @@ describe('Top hit metric', () => {
});

it('should request the _source field', () => {
init({ field: '_source' });
expect(aggDsl.top_hits._source).toBeTruthy();
expect(aggDsl.top_hits.docvalue_fields).toBeUndefined();
init({ fieldName: '_source' });
expect(aggDsl.top_hits._source).toBe(true);
expect(aggDsl.top_hits.fields).toBeUndefined();
});

it('requests both source and docvalues_fields for non-text aggregatable fields', () => {
it('requests fields for non-text aggregatable fields', () => {
init({ fieldName: 'bytes', readFromDocValues: true });
expect(aggDsl.top_hits._source).toBe('bytes');
expect(aggDsl.top_hits.docvalue_fields).toEqual([{ field: 'bytes' }]);
expect(aggDsl.top_hits._source).toBe(false);
expect(aggDsl.top_hits.fields).toEqual([{ field: 'bytes' }]);
});

it('requests both source and docvalues_fields for date aggregatable fields', () => {
it('requests fields for date aggregatable fields', () => {
init({ fieldName: '@timestamp', readFromDocValues: true, fieldType: KBN_FIELD_TYPES.DATE });

expect(aggDsl.top_hits._source).toBe('@timestamp');
expect(aggDsl.top_hits.docvalue_fields).toEqual([{ field: '@timestamp', format: 'date_time' }]);
expect(aggDsl.top_hits._source).toBe(false);
expect(aggDsl.top_hits.fields).toEqual([{ field: '@timestamp', format: 'date_time' }]);
});

it('requests just source for aggregatable text fields', () => {
it('requests fields for aggregatable text fields', () => {
init({ fieldName: 'machine.os' });
expect(aggDsl.top_hits._source).toBe('machine.os');
expect(aggDsl.top_hits.docvalue_fields).toBeUndefined();
expect(aggDsl.top_hits._source).toBe(false);
expect(aggDsl.top_hits.fields).toEqual([{ field: 'machine.os' }]);
});

describe('try to get the value from the top hit', () => {
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/data/common/search/aggs/metrics/top_hit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ export const getTopHitMetricAgg = () => {
},
};
} else {
if (field.readFromDocValues) {
output.params.docvalue_fields = [
if (field.name !== '_source') {
output.params.fields = [
{
field: field.name,
// always format date fields as date_time to avoid
Expand All @@ -89,7 +89,7 @@ export const getTopHitMetricAgg = () => {
},
];
}
output.params._source = field.name === '_source' ? true : field.name;
output.params._source = field.name === '_source';
}
},
},
Expand Down