Skip to content

Commit

Permalink
test esaggs fn generation for terms op
Browse files Browse the repository at this point in the history
  • Loading branch information
drewdaemon committed Apr 1, 2022
1 parent 18461ff commit 7553381
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,29 @@ describe('terms', () => {
);
});

it('should add shard size if accuracy mode enabled', () => {
const termsColumn = layer.columns.col1 as TermsIndexPatternColumn;
const getEsAggsFnArgs = (accuracyMode: boolean, size: number) =>
termsOperation.toEsAggsFn(
{
...termsColumn,
params: { ...termsColumn.params, otherBucket: true, accuracyMode, size },
},
'col1',
{} as IndexPattern,
layer,
uiSettingsMock,
[]
).arguments;

const smallSize = 5;
const bigSize = 900;

expect(getEsAggsFnArgs(true, smallSize).shardSize?.[0]).toEqual(1000);
expect(getEsAggsFnArgs(true, bigSize).shardSize?.[0]).toEqual(1360);
expect(getEsAggsFnArgs(false, smallSize).shardSize).not.toBeDefined();
});

it('should reflect rare terms params correctly', () => {
const termsColumn = layer.columns.col1 as TermsIndexPatternColumn;
const esAggsFn = termsOperation.toEsAggsFn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface TermsIndexPatternColumn extends FieldBasedIndexPatternColumn {
params: {
size: number;
// accuracy mode is accomplished by increasing shard_size
accuracyMode: boolean | undefined;
accuracyMode?: boolean;
// if order is alphabetical, the `fallback` flag indicates whether it became alphabetical because there wasn't
// another option or whether the user explicitly chose to make it alphabetical.
orderBy:
Expand Down

0 comments on commit 7553381

Please sign in to comment.