@redis/search 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +120 -0
  2. package/dist/commands/AGGREGATE.d.ts +114 -0
  3. package/dist/commands/AGGREGATE.js +162 -0
  4. package/dist/commands/ALIASADD.d.ts +2 -0
  5. package/dist/commands/ALIASADD.js +7 -0
  6. package/dist/commands/ALIASDEL.d.ts +2 -0
  7. package/dist/commands/ALIASDEL.js +7 -0
  8. package/dist/commands/ALIASUPDATE.d.ts +2 -0
  9. package/dist/commands/ALIASUPDATE.js +7 -0
  10. package/dist/commands/ALTER.d.ts +3 -0
  11. package/dist/commands/ALTER.js +10 -0
  12. package/dist/commands/CONFIG_GET.d.ts +6 -0
  13. package/dist/commands/CONFIG_GET.js +15 -0
  14. package/dist/commands/CONFIG_SET.d.ts +2 -0
  15. package/dist/commands/CONFIG_SET.js +7 -0
  16. package/dist/commands/CREATE.d.ts +21 -0
  17. package/dist/commands/CREATE.js +56 -0
  18. package/dist/commands/DICTADD.d.ts +3 -0
  19. package/dist/commands/DICTADD.js +8 -0
  20. package/dist/commands/DICTDEL.d.ts +3 -0
  21. package/dist/commands/DICTDEL.js +8 -0
  22. package/dist/commands/DICTDUMP.d.ts +2 -0
  23. package/dist/commands/DICTDUMP.js +7 -0
  24. package/dist/commands/DROPINDEX.d.ts +6 -0
  25. package/dist/commands/DROPINDEX.js +11 -0
  26. package/dist/commands/EXPLAIN.d.ts +9 -0
  27. package/dist/commands/EXPLAIN.js +14 -0
  28. package/dist/commands/EXPLAINCLI.d.ts +3 -0
  29. package/dist/commands/EXPLAINCLI.js +8 -0
  30. package/dist/commands/INFO.d.ts +120 -0
  31. package/dist/commands/INFO.js +51 -0
  32. package/dist/commands/PROFILE_AGGREGATE.d.ts +7 -0
  33. package/dist/commands/PROFILE_AGGREGATE.js +23 -0
  34. package/dist/commands/PROFILE_SEARCH.d.ts +8 -0
  35. package/dist/commands/PROFILE_SEARCH.js +22 -0
  36. package/dist/commands/SEARCH.d.ts +40 -0
  37. package/dist/commands/SEARCH.js +28 -0
  38. package/dist/commands/SPELLCHECK.d.ts +24 -0
  39. package/dist/commands/SPELLCHECK.js +37 -0
  40. package/dist/commands/SUGADD.d.ts +7 -0
  41. package/dist/commands/SUGADD.js +14 -0
  42. package/dist/commands/SUGDEL.d.ts +2 -0
  43. package/dist/commands/SUGDEL.js +9 -0
  44. package/dist/commands/SUGGET.d.ts +7 -0
  45. package/dist/commands/SUGGET.js +15 -0
  46. package/dist/commands/SUGGET_WITHPAYLOADS.d.ts +8 -0
  47. package/dist/commands/SUGGET_WITHPAYLOADS.js +26 -0
  48. package/dist/commands/SUGGET_WITHSCORES.d.ts +8 -0
  49. package/dist/commands/SUGGET_WITHSCORES.js +26 -0
  50. package/dist/commands/SUGGET_WITHSCORES_WITHPAYLOADS.d.ts +7 -0
  51. package/dist/commands/SUGGET_WITHSCORES_WITHPAYLOADS.js +28 -0
  52. package/dist/commands/SUGLEN.d.ts +3 -0
  53. package/dist/commands/SUGLEN.js +8 -0
  54. package/dist/commands/SYNDUMP.d.ts +2 -0
  55. package/dist/commands/SYNDUMP.js +7 -0
  56. package/dist/commands/SYNUPDATE.d.ts +7 -0
  57. package/dist/commands/SYNUPDATE.js +12 -0
  58. package/dist/commands/TAGVALS.d.ts +2 -0
  59. package/dist/commands/TAGVALS.js +7 -0
  60. package/dist/commands/_LIST.d.ts +2 -0
  61. package/dist/commands/_LIST.js +7 -0
  62. package/dist/commands/index.d.ts +240 -0
  63. package/dist/commands/index.js +409 -0
  64. package/dist/index.d.ts +4 -0
  65. package/dist/index.js +12 -0
  66. package/package.json +29 -0
package/README.md ADDED
@@ -0,0 +1,120 @@
1
+ # @redis/search
2
+
3
+ This package provides support for the [RediSearch](https://redisearch.io) module, which adds indexing and querying support for data stored in Redis Hashes or as JSON documents with the RedisJSON module. It extends the [Node Redis client](https://github.com/redis/node-redis) to include functions for each of the RediSearch commands.
4
+
5
+ To use these extra commands, your Redis server must have the RediSearch module installed. To index and query JSON documents, you'll also need to add the RedisJSON module.
6
+
7
+ ## Usage
8
+
9
+ For complete examples, see [`search-hashes.js`](https://github.com/redis/node-redis/blob/master/examples/search-hashes.js) and [`search-json.js`](https://github.com/redis/node-redis/blob/master/examples/search-json.js) in the Node Redis examples folder.
10
+
11
+ ### Indexing and Querying Data in Redis Hashes
12
+
13
+ #### Creating an Index
14
+
15
+ Before we can perform any searches, we need to tell RediSearch how to index our data, and which Redis keys to find that data in. The [FT.CREATE](https://oss.redis.com/redisearch/Commands/#ftcreate) command creates a RediSearch index. Here's how to use it to create an index we'll call `idx:animals` where we want to index hashes containing `name`, `species` and `age` fields, and whose key names in Redis begin with the prefix `noderedis:animals`:
16
+
17
+ ```javascript
18
+ await client.ft.create('idx:animals', {
19
+ name: {
20
+ type: SchemaFieldTypes.TEXT,
21
+ sortable: true
22
+ },
23
+ species: SchemaFieldTypes.TAG,
24
+ age: SchemaFieldTypes.NUMERIC
25
+ }, {
26
+ ON: 'HASH',
27
+ PREFIX: 'noderedis:animals'
28
+ }
29
+ );
30
+ ```
31
+
32
+ See the [`FT.CREATE` documentation](https://oss.redis.com/redisearch/Commands/#ftcreate) for information about the different field types and additional options.
33
+
34
+ #### Querying the Index
35
+
36
+ Once we've created an index, and added some data to Redis hashes whose keys begin with the prefix `noderedis:animals`, we can start writing some search queries. RediSearch supports a rich query syntax for full-text search, faceted search, aggregation and more. Check out the [`FT.SEARCH` documentation](https://oss.redis.com/redisearch/Commands/#ftsearch) and the [query syntax reference](https://oss.redis.com/redisearch/Query_Syntax/) for more information.
37
+
38
+ Let's write a query to find all the animals where the `species` field has the value `dog`:
39
+
40
+ ```javascript
41
+ const results = await client.ft.search('idx:animals', '@species:{dog}');
42
+ ```
43
+
44
+ `results` looks like this:
45
+
46
+ ```javascript
47
+ {
48
+ total: 2,
49
+ documents: [
50
+ {
51
+ id: 'noderedis:animals:4',
52
+ value: {
53
+ name: 'Fido',
54
+ species: 'dog',
55
+ age: '7'
56
+ }
57
+ },
58
+ {
59
+ id: 'noderedis:animals:3',
60
+ value: {
61
+ name: 'Rover',
62
+ species: 'dog',
63
+ age: '9'
64
+ }
65
+ }
66
+ ]
67
+ }
68
+ ```
69
+
70
+ ### Indexing and Querying Data with RedisJSON
71
+
72
+ RediSearch can also index and query JSON documents stored in Redis using the RedisJSON module. The approach is similar to that for indexing and searching data in hashes, but we can now use JSON Path like syntax and the data no longer has to be flat name/value pairs - it can contain nested objects and arrays.
73
+
74
+ #### Creating an Index
75
+
76
+ As before, we create an index with the `FT.CREATE` command, this time specifying we want to index JSON documents that look like this:
77
+
78
+ ```javascript
79
+ {
80
+ name: 'Alice',
81
+ age: 32,
82
+ coins: 100
83
+ }
84
+ ```
85
+
86
+ Each document represents a user in some system, and users have name, age and coins properties.
87
+
88
+ One way we might choose to index these documents is as follows:
89
+
90
+ ```javascript
91
+ await client.ft.create('idx:users', {
92
+ '$.name': {
93
+ type: SchemaFieldTypes.TEXT,
94
+ SORTABLE: 'UNF'
95
+ },
96
+ '$.age': {
97
+ type: SchemaFieldTypes.NUMERIC,
98
+ AS: 'age'
99
+ },
100
+ '$.coins': {
101
+ type: SchemaFieldTypes.NUMERIC,
102
+ AS: 'coins'
103
+ }
104
+ }, {
105
+ ON: 'JSON',
106
+ PREFIX: 'noderedis:users'
107
+ });
108
+ ```
109
+
110
+ Note that we're using JSON Path to specify where the fields to index are in our JSON documents, and the `AS` clause to define a name/alias for each field. We'll use these when writing queries.
111
+
112
+ #### Querying the Index
113
+
114
+ Now we have an index and some data stored as JSON documents in Redis (see the [JSON package documentation](https://github.com/redis/node-redis/tree/master/packages/json) for examples of how to store JSON), we can write some queries...
115
+
116
+ We'll use the [RediSearch query language](https://oss.redis.com/redisearch/Query_Syntax/) and [`FT.SEARCH`](https://oss.redis.com/redisearch/Commands/#ftsearch) command. Here's a query to find users under the age of 30:
117
+
118
+ ```javascript
119
+ await client.ft.search('idx:users', '@age:[0 30]');
120
+ ```
@@ -0,0 +1,114 @@
1
+ import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands';
2
+ import { Params, PropertyName, SortByProperty } from '.';
3
+ export declare enum AggregateSteps {
4
+ GROUPBY = "GROUPBY",
5
+ SORTBY = "SORTBY",
6
+ APPLY = "APPLY",
7
+ LIMIT = "LIMIT",
8
+ FILTER = "FILTER"
9
+ }
10
+ interface AggregateStep<T extends AggregateSteps> {
11
+ type: T;
12
+ }
13
+ export declare enum AggregateGroupByReducers {
14
+ COUNT = "COUNT",
15
+ COUNT_DISTINCT = "COUNT_DISTINCT",
16
+ COUNT_DISTINCTISH = "COUNT_DISTINCTISH",
17
+ SUM = "SUM",
18
+ MIN = "MIN",
19
+ MAX = "MAX",
20
+ AVG = "AVG",
21
+ STDDEV = "STDDEV",
22
+ QUANTILE = "QUANTILE",
23
+ TOLIST = "TOLIST",
24
+ TO_LIST = "TOLIST",
25
+ FIRST_VALUE = "FIRST_VALUE",
26
+ RANDOM_SAMPLE = "RANDOM_SAMPLE"
27
+ }
28
+ interface GroupByReducer<T extends AggregateGroupByReducers> {
29
+ type: T;
30
+ AS?: string;
31
+ }
32
+ declare type CountReducer = GroupByReducer<AggregateGroupByReducers.COUNT>;
33
+ interface CountDistinctReducer extends GroupByReducer<AggregateGroupByReducers.COUNT_DISTINCT> {
34
+ property: PropertyName;
35
+ }
36
+ interface CountDistinctishReducer extends GroupByReducer<AggregateGroupByReducers.COUNT_DISTINCTISH> {
37
+ property: PropertyName;
38
+ }
39
+ interface SumReducer extends GroupByReducer<AggregateGroupByReducers.SUM> {
40
+ property: PropertyName;
41
+ }
42
+ interface MinReducer extends GroupByReducer<AggregateGroupByReducers.MIN> {
43
+ property: PropertyName;
44
+ }
45
+ interface MaxReducer extends GroupByReducer<AggregateGroupByReducers.MAX> {
46
+ property: PropertyName;
47
+ }
48
+ interface AvgReducer extends GroupByReducer<AggregateGroupByReducers.AVG> {
49
+ property: PropertyName;
50
+ }
51
+ interface StdDevReducer extends GroupByReducer<AggregateGroupByReducers.STDDEV> {
52
+ property: PropertyName;
53
+ }
54
+ interface QuantileReducer extends GroupByReducer<AggregateGroupByReducers.QUANTILE> {
55
+ property: PropertyName;
56
+ quantile: number;
57
+ }
58
+ interface ToListReducer extends GroupByReducer<AggregateGroupByReducers.TOLIST> {
59
+ property: PropertyName;
60
+ }
61
+ interface FirstValueReducer extends GroupByReducer<AggregateGroupByReducers.FIRST_VALUE> {
62
+ property: PropertyName;
63
+ BY?: PropertyName | {
64
+ property: PropertyName;
65
+ direction?: 'ASC' | 'DESC';
66
+ };
67
+ }
68
+ interface RandomSampleReducer extends GroupByReducer<AggregateGroupByReducers.RANDOM_SAMPLE> {
69
+ property: PropertyName;
70
+ sampleSize: number;
71
+ }
72
+ declare type GroupByReducers = CountReducer | CountDistinctReducer | CountDistinctishReducer | SumReducer | MinReducer | MaxReducer | AvgReducer | StdDevReducer | QuantileReducer | ToListReducer | FirstValueReducer | RandomSampleReducer;
73
+ interface GroupByStep extends AggregateStep<AggregateSteps.GROUPBY> {
74
+ properties?: PropertyName | Array<PropertyName>;
75
+ REDUCE: GroupByReducers | Array<GroupByReducers>;
76
+ }
77
+ interface SortStep extends AggregateStep<AggregateSteps.SORTBY> {
78
+ BY: SortByProperty | Array<SortByProperty>;
79
+ MAX?: number;
80
+ }
81
+ interface ApplyStep extends AggregateStep<AggregateSteps.APPLY> {
82
+ expression: string;
83
+ AS: string;
84
+ }
85
+ interface LimitStep extends AggregateStep<AggregateSteps.LIMIT> {
86
+ from: number;
87
+ size: number;
88
+ }
89
+ interface FilterStep extends AggregateStep<AggregateSteps.FILTER> {
90
+ expression: string;
91
+ }
92
+ declare type LoadField = PropertyName | {
93
+ identifier: PropertyName;
94
+ AS?: string;
95
+ };
96
+ export interface AggregateOptions {
97
+ VERBATIM?: true;
98
+ LOAD?: LoadField | Array<LoadField>;
99
+ STEPS?: Array<GroupByStep | SortStep | ApplyStep | LimitStep | FilterStep>;
100
+ PARAMS?: Params;
101
+ DIALECT?: number;
102
+ }
103
+ export declare function transformArguments(index: string, query: string, options?: AggregateOptions): RedisCommandArguments;
104
+ export declare function pushAggregatehOptions(args: RedisCommandArguments, options?: AggregateOptions): RedisCommandArguments;
105
+ export declare type AggregateRawReply = [
106
+ total: number,
107
+ ...results: Array<Array<RedisCommandArgument>>
108
+ ];
109
+ export interface AggregateReply {
110
+ total: number;
111
+ results: Array<Record<string, RedisCommandArgument>>;
112
+ }
113
+ export declare function transformReply(rawReply: AggregateRawReply): AggregateReply;
114
+ export {};
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformReply = exports.pushAggregatehOptions = exports.transformArguments = exports.AggregateGroupByReducers = exports.AggregateSteps = void 0;
4
+ const generic_transformers_1 = require("@redis/client/dist/lib/commands/generic-transformers");
5
+ const _1 = require(".");
6
+ var AggregateSteps;
7
+ (function (AggregateSteps) {
8
+ AggregateSteps["GROUPBY"] = "GROUPBY";
9
+ AggregateSteps["SORTBY"] = "SORTBY";
10
+ AggregateSteps["APPLY"] = "APPLY";
11
+ AggregateSteps["LIMIT"] = "LIMIT";
12
+ AggregateSteps["FILTER"] = "FILTER";
13
+ })(AggregateSteps = exports.AggregateSteps || (exports.AggregateSteps = {}));
14
+ var AggregateGroupByReducers;
15
+ (function (AggregateGroupByReducers) {
16
+ AggregateGroupByReducers["COUNT"] = "COUNT";
17
+ AggregateGroupByReducers["COUNT_DISTINCT"] = "COUNT_DISTINCT";
18
+ AggregateGroupByReducers["COUNT_DISTINCTISH"] = "COUNT_DISTINCTISH";
19
+ AggregateGroupByReducers["SUM"] = "SUM";
20
+ AggregateGroupByReducers["MIN"] = "MIN";
21
+ AggregateGroupByReducers["MAX"] = "MAX";
22
+ AggregateGroupByReducers["AVG"] = "AVG";
23
+ AggregateGroupByReducers["STDDEV"] = "STDDEV";
24
+ AggregateGroupByReducers["QUANTILE"] = "QUANTILE";
25
+ AggregateGroupByReducers["TOLIST"] = "TOLIST";
26
+ AggregateGroupByReducers["TO_LIST"] = "TOLIST";
27
+ AggregateGroupByReducers["FIRST_VALUE"] = "FIRST_VALUE";
28
+ AggregateGroupByReducers["RANDOM_SAMPLE"] = "RANDOM_SAMPLE";
29
+ })(AggregateGroupByReducers = exports.AggregateGroupByReducers || (exports.AggregateGroupByReducers = {}));
30
+ function transformArguments(index, query, options) {
31
+ return pushAggregatehOptions(['FT.AGGREGATE', index, query], options);
32
+ }
33
+ exports.transformArguments = transformArguments;
34
+ function pushAggregatehOptions(args, options) {
35
+ if (options?.VERBATIM) {
36
+ args.push('VERBATIM');
37
+ }
38
+ if (options?.LOAD) {
39
+ args.push('LOAD');
40
+ (0, _1.pushArgumentsWithLength)(args, () => {
41
+ if (Array.isArray(options.LOAD)) {
42
+ for (const load of options.LOAD) {
43
+ pushLoadField(args, load);
44
+ }
45
+ }
46
+ else {
47
+ pushLoadField(args, options.LOAD);
48
+ }
49
+ });
50
+ }
51
+ if (options?.STEPS) {
52
+ for (const step of options.STEPS) {
53
+ switch (step.type) {
54
+ case AggregateSteps.GROUPBY:
55
+ args.push('GROUPBY');
56
+ if (!step.properties) {
57
+ args.push('0');
58
+ }
59
+ else {
60
+ (0, generic_transformers_1.pushVerdictArgument)(args, step.properties);
61
+ }
62
+ if (Array.isArray(step.REDUCE)) {
63
+ for (const reducer of step.REDUCE) {
64
+ pushGroupByReducer(args, reducer);
65
+ }
66
+ }
67
+ else {
68
+ pushGroupByReducer(args, step.REDUCE);
69
+ }
70
+ break;
71
+ case AggregateSteps.SORTBY:
72
+ (0, _1.pushSortByArguments)(args, 'SORTBY', step.BY);
73
+ if (step.MAX) {
74
+ args.push('MAX', step.MAX.toString());
75
+ }
76
+ break;
77
+ case AggregateSteps.APPLY:
78
+ args.push('APPLY', step.expression, 'AS', step.AS);
79
+ break;
80
+ case AggregateSteps.LIMIT:
81
+ args.push('LIMIT', step.from.toString(), step.size.toString());
82
+ break;
83
+ case AggregateSteps.FILTER:
84
+ args.push('FILTER', step.expression);
85
+ break;
86
+ }
87
+ }
88
+ }
89
+ (0, _1.pushParamsArgs)(args, options?.PARAMS);
90
+ if (options?.DIALECT) {
91
+ args.push('DIALECT', options.DIALECT.toString());
92
+ }
93
+ return args;
94
+ }
95
+ exports.pushAggregatehOptions = pushAggregatehOptions;
96
+ function pushLoadField(args, toLoad) {
97
+ if (typeof toLoad === 'string') {
98
+ args.push(toLoad);
99
+ }
100
+ else {
101
+ args.push(toLoad.identifier);
102
+ if (toLoad.AS) {
103
+ args.push('AS', toLoad.AS);
104
+ }
105
+ }
106
+ }
107
+ function pushGroupByReducer(args, reducer) {
108
+ args.push('REDUCE', reducer.type);
109
+ switch (reducer.type) {
110
+ case AggregateGroupByReducers.COUNT:
111
+ args.push('0');
112
+ break;
113
+ case AggregateGroupByReducers.COUNT_DISTINCT:
114
+ case AggregateGroupByReducers.COUNT_DISTINCTISH:
115
+ case AggregateGroupByReducers.SUM:
116
+ case AggregateGroupByReducers.MIN:
117
+ case AggregateGroupByReducers.MAX:
118
+ case AggregateGroupByReducers.AVG:
119
+ case AggregateGroupByReducers.STDDEV:
120
+ case AggregateGroupByReducers.TOLIST:
121
+ args.push('1', reducer.property);
122
+ break;
123
+ case AggregateGroupByReducers.QUANTILE:
124
+ args.push('2', reducer.property, reducer.quantile.toString());
125
+ break;
126
+ case AggregateGroupByReducers.FIRST_VALUE: {
127
+ (0, _1.pushArgumentsWithLength)(args, () => {
128
+ args.push(reducer.property);
129
+ if (reducer.BY) {
130
+ args.push('BY');
131
+ if (typeof reducer.BY === 'string') {
132
+ args.push(reducer.BY);
133
+ }
134
+ else {
135
+ args.push(reducer.BY.property);
136
+ if (reducer.BY.direction) {
137
+ args.push(reducer.BY.direction);
138
+ }
139
+ }
140
+ }
141
+ });
142
+ break;
143
+ }
144
+ case AggregateGroupByReducers.RANDOM_SAMPLE:
145
+ args.push('2', reducer.property, reducer.sampleSize.toString());
146
+ break;
147
+ }
148
+ if (reducer.AS) {
149
+ args.push('AS', reducer.AS);
150
+ }
151
+ }
152
+ function transformReply(rawReply) {
153
+ const results = [];
154
+ for (let i = 1; i < rawReply.length; i++) {
155
+ results.push((0, generic_transformers_1.transformTuplesReply)(rawReply[i]));
156
+ }
157
+ return {
158
+ total: rawReply[0],
159
+ results
160
+ };
161
+ }
162
+ exports.transformReply = transformReply;
@@ -0,0 +1,2 @@
1
+ export declare function transformArguments(name: string, index: string): Array<string>;
2
+ export declare function transformReply(): 'OK';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformArguments = void 0;
4
+ function transformArguments(name, index) {
5
+ return ['FT.ALIASADD', name, index];
6
+ }
7
+ exports.transformArguments = transformArguments;
@@ -0,0 +1,2 @@
1
+ export declare function transformArguments(name: string, index: string): Array<string>;
2
+ export declare function transformReply(): 'OK';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformArguments = void 0;
4
+ function transformArguments(name, index) {
5
+ return ['FT.ALIASDEL', name, index];
6
+ }
7
+ exports.transformArguments = transformArguments;
@@ -0,0 +1,2 @@
1
+ export declare function transformArguments(name: string, index: string): Array<string>;
2
+ export declare function transformReply(): 'OK';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformArguments = void 0;
4
+ function transformArguments(name, index) {
5
+ return ['FT.ALIASUPDATE', name, index];
6
+ }
7
+ exports.transformArguments = transformArguments;
@@ -0,0 +1,3 @@
1
+ import { RediSearchSchema } from '.';
2
+ export declare function transformArguments(index: string, schema: RediSearchSchema): Array<string>;
3
+ export declare function transformReply(): 'OK';
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformArguments = void 0;
4
+ const _1 = require(".");
5
+ function transformArguments(index, schema) {
6
+ const args = ['FT.ALTER', index, 'SCHEMA', 'ADD'];
7
+ (0, _1.pushSchema)(args, schema);
8
+ return args;
9
+ }
10
+ exports.transformArguments = transformArguments;
@@ -0,0 +1,6 @@
1
+ export declare function transformArguments(option: string): string[];
2
+ interface ConfigGetReply {
3
+ [option: string]: string | null;
4
+ }
5
+ export declare function transformReply(rawReply: Array<[string, string | null]>): ConfigGetReply;
6
+ export {};
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformReply = exports.transformArguments = void 0;
4
+ function transformArguments(option) {
5
+ return ['FT.CONFIG', 'GET', option];
6
+ }
7
+ exports.transformArguments = transformArguments;
8
+ function transformReply(rawReply) {
9
+ const transformedReply = Object.create(null);
10
+ for (const [key, value] of rawReply) {
11
+ transformedReply[key] = value;
12
+ }
13
+ return transformedReply;
14
+ }
15
+ exports.transformReply = transformReply;
@@ -0,0 +1,2 @@
1
+ export declare function transformArguments(option: string, value: string): Array<string>;
2
+ export declare function transformReply(): 'OK';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformArguments = void 0;
4
+ function transformArguments(option, value) {
5
+ return ['FT.CONFIG', 'SET', option, value];
6
+ }
7
+ exports.transformArguments = transformArguments;
@@ -0,0 +1,21 @@
1
+ import { RedisSearchLanguages, PropertyName, RediSearchSchema } from '.';
2
+ interface CreateOptions {
3
+ ON?: 'HASH' | 'JSON';
4
+ PREFIX?: string | Array<string>;
5
+ FILTER?: string;
6
+ LANGUAGE?: RedisSearchLanguages;
7
+ LANGUAGE_FIELD?: PropertyName;
8
+ SCORE?: number;
9
+ SCORE_FIELD?: PropertyName;
10
+ MAXTEXTFIELDS?: true;
11
+ TEMPORARY?: number;
12
+ NOOFFSETS?: true;
13
+ NOHL?: true;
14
+ NOFIELDS?: true;
15
+ NOFREQS?: true;
16
+ SKIPINITIALSCAN?: true;
17
+ STOPWORDS?: string | Array<string>;
18
+ }
19
+ export declare function transformArguments(index: string, schema: RediSearchSchema, options?: CreateOptions): Array<string>;
20
+ export declare function transformReply(): 'OK';
21
+ export {};
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformArguments = void 0;
4
+ const generic_transformers_1 = require("@redis/client/dist/lib/commands/generic-transformers");
5
+ const _1 = require(".");
6
+ function transformArguments(index, schema, options) {
7
+ const args = ['FT.CREATE', index];
8
+ if (options?.ON) {
9
+ args.push('ON', options.ON);
10
+ }
11
+ (0, generic_transformers_1.pushOptionalVerdictArgument)(args, 'PREFIX', options?.PREFIX);
12
+ if (options?.FILTER) {
13
+ args.push('FILTER', options.FILTER);
14
+ }
15
+ if (options?.LANGUAGE) {
16
+ args.push('LANGUAGE', options.LANGUAGE);
17
+ }
18
+ if (options?.LANGUAGE_FIELD) {
19
+ args.push('LANGUAGE_FIELD', options.LANGUAGE_FIELD);
20
+ }
21
+ if (options?.SCORE) {
22
+ args.push('SCORE', options.SCORE.toString());
23
+ }
24
+ if (options?.SCORE_FIELD) {
25
+ args.push('SCORE_FIELD', options.SCORE_FIELD);
26
+ }
27
+ // if (options?.PAYLOAD_FIELD) {
28
+ // args.push('PAYLOAD_FIELD', options.PAYLOAD_FIELD);
29
+ // }
30
+ if (options?.MAXTEXTFIELDS) {
31
+ args.push('MAXTEXTFIELDS');
32
+ }
33
+ if (options?.TEMPORARY) {
34
+ args.push('TEMPORARY', options.TEMPORARY.toString());
35
+ }
36
+ if (options?.NOOFFSETS) {
37
+ args.push('NOOFFSETS');
38
+ }
39
+ if (options?.NOHL) {
40
+ args.push('NOHL');
41
+ }
42
+ if (options?.NOFIELDS) {
43
+ args.push('NOFIELDS');
44
+ }
45
+ if (options?.NOFREQS) {
46
+ args.push('NOFREQS');
47
+ }
48
+ if (options?.SKIPINITIALSCAN) {
49
+ args.push('SKIPINITIALSCAN');
50
+ }
51
+ (0, generic_transformers_1.pushOptionalVerdictArgument)(args, 'STOPWORDS', options?.STOPWORDS);
52
+ args.push('SCHEMA');
53
+ (0, _1.pushSchema)(args, schema);
54
+ return args;
55
+ }
56
+ exports.transformArguments = transformArguments;
@@ -0,0 +1,3 @@
1
+ import { RedisCommandArguments } from '@redis/client/dist/lib/commands';
2
+ export declare function transformArguments(dictionary: string, term: string | Array<string>): RedisCommandArguments;
3
+ export declare function transformReply(): number;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformArguments = void 0;
4
+ const generic_transformers_1 = require("@redis/client/dist/lib/commands/generic-transformers");
5
+ function transformArguments(dictionary, term) {
6
+ return (0, generic_transformers_1.pushVerdictArguments)(['FT.DICTADD', dictionary], term);
7
+ }
8
+ exports.transformArguments = transformArguments;
@@ -0,0 +1,3 @@
1
+ import { RedisCommandArguments } from '@redis/client/dist/lib/commands';
2
+ export declare function transformArguments(dictionary: string, term: string | Array<string>): RedisCommandArguments;
3
+ export declare function transformReply(): number;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformArguments = void 0;
4
+ const generic_transformers_1 = require("@redis/client/dist/lib/commands/generic-transformers");
5
+ function transformArguments(dictionary, term) {
6
+ return (0, generic_transformers_1.pushVerdictArguments)(['FT.DICTDEL', dictionary], term);
7
+ }
8
+ exports.transformArguments = transformArguments;
@@ -0,0 +1,2 @@
1
+ export declare function transformArguments(dictionary: string): Array<string>;
2
+ export declare function transformReply(): Array<string>;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformArguments = void 0;
4
+ function transformArguments(dictionary) {
5
+ return ['FT.DICTDUMP', dictionary];
6
+ }
7
+ exports.transformArguments = transformArguments;
@@ -0,0 +1,6 @@
1
+ interface DropIndexOptions {
2
+ DD?: true;
3
+ }
4
+ export declare function transformArguments(index: string, options?: DropIndexOptions): Array<string>;
5
+ export declare function transformReply(): 'OK';
6
+ export {};
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformArguments = void 0;
4
+ function transformArguments(index, options) {
5
+ const args = ['FT.DROPINDEX', index];
6
+ if (options?.DD) {
7
+ args.push('DD');
8
+ }
9
+ return args;
10
+ }
11
+ exports.transformArguments = transformArguments;
@@ -0,0 +1,9 @@
1
+ import { Params } from ".";
2
+ export declare const IS_READ_ONLY = true;
3
+ interface ExplainOptions {
4
+ PARAMS?: Params;
5
+ DIALECT?: number;
6
+ }
7
+ export declare function transformArguments(index: string, query: string, options?: ExplainOptions): Array<string>;
8
+ export declare function transformReply(): string;
9
+ export {};
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformArguments = exports.IS_READ_ONLY = void 0;
4
+ const _1 = require(".");
5
+ exports.IS_READ_ONLY = true;
6
+ function transformArguments(index, query, options) {
7
+ const args = ['FT.EXPLAIN', index, query];
8
+ (0, _1.pushParamsArgs)(args, options?.PARAMS);
9
+ if (options?.DIALECT) {
10
+ args.push('DIALECT', options.DIALECT.toString());
11
+ }
12
+ return args;
13
+ }
14
+ exports.transformArguments = transformArguments;
@@ -0,0 +1,3 @@
1
+ export declare const IS_READ_ONLY = true;
2
+ export declare function transformArguments(index: string, query: string): Array<string>;
3
+ export declare function transformReply(): Array<string>;