Skip to content

Commit 1f346f8

Browse files
committed
Merge remote-tracking branch 'upstream/v5' into v5-search-broken
2 parents e1b935c + 2eaaa58 commit 1f346f8

File tree

12 files changed

+123
-20
lines changed

12 files changed

+123
-20
lines changed

packages/search/lib/commands/AGGREGATE.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ describe('AGGREGATE', () => {
2020
);
2121
});
2222

23+
it('with ADDSCORES', () => {
24+
assert.deepEqual(
25+
AGGREGATE.transformArguments('index', '*', { ADDSCORES: true }),
26+
['FT.AGGREGATE', 'index', '*', 'ADDSCORES']
27+
);
28+
});
29+
2330
describe('with LOAD', () => {
2431
describe('single', () => {
2532
describe('without alias', () => {

packages/search/lib/commands/AGGREGATE.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ interface FilterStep extends AggregateStep<FT_AGGREGATE_STEPS['FILTER']> {
118118

119119
export interface FtAggregateOptions {
120120
VERBATIM?: boolean;
121+
ADDSCORES?: boolean;
121122
LOAD?: LoadField | Array<LoadField>;
122123
TIMEOUT?: number;
123124
STEPS?: Array<GroupByStep | SortStep | ApplyStep | LimitStep | FilterStep>;
@@ -167,6 +168,10 @@ export function pushAggregateOptions(args: Array<RedisArgument>, options?: FtAgg
167168
args.push('VERBATIM');
168169
}
169170

171+
if (options?.ADDSCORES) {
172+
args.push('ADDSCORES');
173+
}
174+
170175
if (options?.LOAD) {
171176
const length = args.push('LOAD', '');
172177

packages/time-series/lib/commands/ADD.spec.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,29 @@ describe('TS.ADD', () => {
5757
);
5858
});
5959

60-
it('with RETENTION, ENCODING, CHUNK_SIZE, ON_DUPLICATE, LABELS', () => {
60+
it ('with IGNORE', () => {
61+
assert.deepEqual(
62+
ADD.transformArguments('key', '*', 1, {
63+
IGNORE: {
64+
maxTimeDiff: 1,
65+
maxValDiff: 1
66+
}
67+
}),
68+
['TS.ADD', 'key', '*', '1', 'IGNORE', '1', '1']
69+
)
70+
});
71+
72+
it('with RETENTION, ENCODING, CHUNK_SIZE, ON_DUPLICATE, LABELS, IGNORE', () => {
6173
assert.deepEqual(
6274
ADD.transformArguments('key', '*', 1, {
6375
RETENTION: 1,
6476
ENCODING: TIME_SERIES_ENCODING.UNCOMPRESSED,
6577
CHUNK_SIZE: 1,
6678
ON_DUPLICATE: TIME_SERIES_DUPLICATE_POLICIES.BLOCK,
67-
LABELS: { label: 'value' }
79+
LABELS: { label: 'value' },
80+
IGNORE: { maxTimeDiff: 1, maxValDiff: 1}
6881
}),
69-
['TS.ADD', 'key', '*', '1', 'RETENTION', '1', 'ENCODING', 'UNCOMPRESSED', 'CHUNK_SIZE', '1', 'ON_DUPLICATE', 'BLOCK', 'LABELS', 'label', 'value']
82+
['TS.ADD', 'key', '*', '1', 'RETENTION', '1', 'ENCODING', 'UNCOMPRESSED', 'CHUNK_SIZE', '1', 'ON_DUPLICATE', 'BLOCK', 'LABELS', 'label', 'value', 'IGNORE', '1', '1']
7083
);
7184
});
7285
});

packages/time-series/lib/commands/ADD.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,22 @@ import {
88
TimeSeriesDuplicatePolicies,
99
Labels,
1010
pushLabelsArgument,
11-
Timestamp
11+
Timestamp,
12+
pushIgnoreArgument
1213
} from '.';
1314

15+
export interface TsIgnoreOptions {
16+
maxTimeDiff: number;
17+
maxValDiff: number;
18+
}
19+
1420
export interface TsAddOptions {
1521
RETENTION?: number;
1622
ENCODING?: TimeSeriesEncoding;
1723
CHUNK_SIZE?: number;
1824
ON_DUPLICATE?: TimeSeriesDuplicatePolicies;
1925
LABELS?: Labels;
26+
IGNORE?: TsIgnoreOptions;
2027
}
2128

2229
export default {
@@ -47,6 +54,8 @@ export default {
4754

4855
pushLabelsArgument(args, options?.LABELS);
4956

57+
pushIgnoreArgument(args, options?.IGNORE);
58+
5059
return args;
5160
},
5261
transformReply: undefined as unknown as () => NumberReply

packages/time-series/lib/commands/ALTER.spec.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,28 @@ describe('TS.ALTER', () => {
4848
);
4949
});
5050

51-
it('with RETENTION, CHUNK_SIZE, DUPLICATE_POLICY, LABELS', () => {
51+
it('with IGNORE', () => {
52+
assert.deepEqual(
53+
ALTER.transformArguments('key', {
54+
IGNORE: {
55+
maxTimeDiff: 1,
56+
maxValDiff: 1
57+
}
58+
}),
59+
['TS.ALTER', 'key', 'IGNORE', '1', '1']
60+
)
61+
});
62+
63+
it('with RETENTION, CHUNK_SIZE, DUPLICATE_POLICY, LABELS, IGNORE', () => {
5264
assert.deepEqual(
5365
ALTER.transformArguments('key', {
5466
RETENTION: 1,
5567
CHUNK_SIZE: 1,
5668
DUPLICATE_POLICY: TIME_SERIES_DUPLICATE_POLICIES.BLOCK,
57-
LABELS: { label: 'value' }
69+
LABELS: { label: 'value' },
70+
IGNORE: { maxTimeDiff: 1, maxValDiff: 1}
5871
}),
59-
['TS.ALTER', 'key', 'RETENTION', '1', 'CHUNK_SIZE', '1', 'DUPLICATE_POLICY', 'BLOCK', 'LABELS', 'label', 'value']
72+
['TS.ALTER', 'key', 'RETENTION', '1', 'CHUNK_SIZE', '1', 'DUPLICATE_POLICY', 'BLOCK', 'LABELS', 'label', 'value', 'IGNORE', '1', '1']
6073
);
6174
});
6275
});

packages/time-series/lib/commands/ALTER.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { RedisArgument, SimpleStringReply, Command } from '@redis/client/dist/lib/RESP/types';
22
import { TsCreateOptions } from './CREATE';
3-
import { pushRetentionArgument, pushChunkSizeArgument, pushDuplicatePolicy, pushLabelsArgument } from '.';
3+
import { pushRetentionArgument, pushChunkSizeArgument, pushDuplicatePolicy, pushLabelsArgument, pushIgnoreArgument } from '.';
44

5-
export type TsAlterOptions = Pick<TsCreateOptions, 'RETENTION' | 'CHUNK_SIZE' | 'DUPLICATE_POLICY' | 'LABELS'>;
5+
export type TsAlterOptions = Pick<TsCreateOptions, 'RETENTION' | 'CHUNK_SIZE' | 'DUPLICATE_POLICY' | 'LABELS' | 'IGNORE'>;
66

77
export default {
88
FIRST_KEY_INDEX: 1,
@@ -18,6 +18,8 @@ export default {
1818

1919
pushLabelsArgument(args, options?.LABELS);
2020

21+
pushIgnoreArgument(args, options?.IGNORE);
22+
2123
return args;
2224
},
2325
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>

packages/time-series/lib/commands/CREATE.spec.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,29 @@ describe('TS.CREATE', () => {
5757
);
5858
});
5959

60-
it('with RETENTION, ENCODING, CHUNK_SIZE, DUPLICATE_POLICY, LABELS', () => {
60+
it('with IGNORE', () => {
61+
assert.deepEqual(
62+
CREATE.transformArguments('key', {
63+
IGNORE: {
64+
maxTimeDiff: 1,
65+
maxValDiff: 1
66+
}
67+
}),
68+
['TS.CREATE', 'key', 'IGNORE', '1', '1']
69+
)
70+
});
71+
72+
it('with RETENTION, ENCODING, CHUNK_SIZE, DUPLICATE_POLICY, LABELS, IGNORE', () => {
6173
assert.deepEqual(
6274
CREATE.transformArguments('key', {
6375
RETENTION: 1,
6476
ENCODING: TIME_SERIES_ENCODING.UNCOMPRESSED,
6577
CHUNK_SIZE: 1,
6678
DUPLICATE_POLICY: TIME_SERIES_DUPLICATE_POLICIES.BLOCK,
67-
LABELS: { label: 'value' }
79+
LABELS: { label: 'value' },
80+
IGNORE: { maxTimeDiff: 1, maxValDiff: 1}
6881
}),
69-
['TS.CREATE', 'key', 'RETENTION', '1', 'ENCODING', 'UNCOMPRESSED', 'CHUNK_SIZE', '1', 'DUPLICATE_POLICY', 'BLOCK', 'LABELS', 'label', 'value']
82+
['TS.CREATE', 'key', 'RETENTION', '1', 'ENCODING', 'UNCOMPRESSED', 'CHUNK_SIZE', '1', 'DUPLICATE_POLICY', 'BLOCK', 'LABELS', 'label', 'value', 'IGNORE', '1', '1']
7083
);
7184
});
7285
});

packages/time-series/lib/commands/CREATE.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,18 @@ import {
77
TimeSeriesDuplicatePolicies,
88
pushDuplicatePolicy,
99
Labels,
10-
pushLabelsArgument
10+
pushLabelsArgument,
11+
pushIgnoreArgument
1112
} from '.';
13+
import { TsIgnoreOptions } from './ADD';
1214

1315
export interface TsCreateOptions {
1416
RETENTION?: number;
1517
ENCODING?: TimeSeriesEncoding;
1618
CHUNK_SIZE?: number;
1719
DUPLICATE_POLICY?: TimeSeriesDuplicatePolicies;
1820
LABELS?: Labels;
21+
IGNORE?: TsIgnoreOptions;
1922
}
2023

2124
export default {
@@ -34,6 +37,8 @@ export default {
3437

3538
pushLabelsArgument(args, options?.LABELS);
3639

40+
pushIgnoreArgument(args, options?.IGNORE);
41+
3742
return args;
3843
},
3944
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>

packages/time-series/lib/commands/DECRBY.spec.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,29 @@ describe('TS.DECRBY', () => {
5656
);
5757
});
5858

59+
it ('with IGNORE', () => {
60+
assert.deepEqual(
61+
DECRBY.transformArguments('key', 1, {
62+
IGNORE: {
63+
maxTimeDiff: 1,
64+
maxValDiff: 1
65+
}
66+
}),
67+
['TS.DECRBY', 'key', '1', 'IGNORE', '1', '1']
68+
)
69+
});
70+
5971
it('with TIMESTAMP, RETENTION, UNCOMPRESSED, CHUNK_SIZE and LABELS', () => {
6072
assert.deepEqual(
6173
DECRBY.transformArguments('key', 1, {
6274
TIMESTAMP: '*',
6375
RETENTION: 1,
6476
UNCOMPRESSED: true,
6577
CHUNK_SIZE: 2,
66-
LABELS: { label: 'value' }
78+
LABELS: { label: 'value' },
79+
IGNORE: { maxTimeDiff: 1, maxValDiff: 1 }
6780
}),
68-
['TS.DECRBY', 'key', '1', 'TIMESTAMP', '*', 'RETENTION', '1', 'UNCOMPRESSED', 'CHUNK_SIZE', '2', 'LABELS', 'label', 'value']
81+
['TS.DECRBY', 'key', '1', 'TIMESTAMP', '*', 'RETENTION', '1', 'UNCOMPRESSED', 'CHUNK_SIZE', '2', 'LABELS', 'label', 'value', 'IGNORE', '1', '1']
6982
);
7083
});
7184
});

packages/time-series/lib/commands/INCRBY.spec.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,30 @@ describe('TS.INCRBY', () => {
6565
);
6666
});
6767

68+
it ('with IGNORE', () => {
69+
assert.deepEqual(
70+
INCRBY.transformArguments('key', 1, {
71+
IGNORE: {
72+
maxTimeDiff: 1,
73+
maxValDiff: 1
74+
}
75+
}),
76+
['TS.INCRBY', 'key', '1', 'IGNORE', '1', '1']
77+
)
78+
});
79+
6880
it('with TIMESTAMP, RETENTION, UNCOMPRESSED, CHUNK_SIZE and LABELS', () => {
6981
assert.deepEqual(
7082
INCRBY.transformArguments('key', 1, {
7183
TIMESTAMP: '*',
7284
RETENTION: 1,
7385
UNCOMPRESSED: true,
7486
CHUNK_SIZE: 1,
75-
LABELS: { label: 'value' }
87+
LABELS: { label: 'value' },
88+
IGNORE: { maxTimeDiff: 1, maxValDiff: 1 }
7689
}),
7790
['TS.INCRBY', 'key', '1', 'TIMESTAMP', '*', 'RETENTION', '1', 'UNCOMPRESSED',
78-
'CHUNK_SIZE', '1', 'LABELS', 'label', 'value']
91+
'CHUNK_SIZE', '1', 'LABELS', 'label', 'value', 'IGNORE', '1', '1']
7992
);
8093
});
8194
});

0 commit comments

Comments
 (0)