@redis/search 1.1.0 → 1.1.1
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.
- package/README.md +7 -8
- package/dist/commands/AGGREGATE.d.ts +4 -4
- package/dist/commands/AGGREGATE_WITHCURSOR.d.ts +1 -1
- package/dist/commands/INFO.d.ts +1 -1
- package/dist/commands/PROFILE_AGGREGATE.d.ts +1 -1
- package/dist/commands/PROFILE_SEARCH.d.ts +1 -1
- package/dist/commands/SEARCH.d.ts +1 -1
- package/dist/commands/SEARCH.js +24 -7
- package/dist/commands/SPELLCHECK.d.ts +2 -2
- package/dist/commands/SUGGET_WITHSCORES_WITHPAYLOADS.d.ts +1 -1
- package/dist/commands/index.d.ts +14 -14
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -18,15 +18,14 @@ Before we can perform any searches, we need to tell RediSearch how to index our
|
|
|
18
18
|
await client.ft.create('idx:animals', {
|
|
19
19
|
name: {
|
|
20
20
|
type: SchemaFieldTypes.TEXT,
|
|
21
|
-
|
|
21
|
+
SORTABLE: true
|
|
22
22
|
},
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
);
|
|
23
|
+
species: SchemaFieldTypes.TAG,
|
|
24
|
+
age: SchemaFieldTypes.NUMERIC
|
|
25
|
+
}, {
|
|
26
|
+
ON: 'HASH',
|
|
27
|
+
PREFIX: 'noderedis:animals'
|
|
28
|
+
});
|
|
30
29
|
```
|
|
31
30
|
|
|
32
31
|
See the [`FT.CREATE` documentation](https://oss.redis.com/redisearch/Commands/#ftcreate) for information about the different field types and additional options.
|
|
@@ -29,7 +29,7 @@ interface GroupByReducer<T extends AggregateGroupByReducers> {
|
|
|
29
29
|
type: T;
|
|
30
30
|
AS?: string;
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
type CountReducer = GroupByReducer<AggregateGroupByReducers.COUNT>;
|
|
33
33
|
interface CountDistinctReducer extends GroupByReducer<AggregateGroupByReducers.COUNT_DISTINCT> {
|
|
34
34
|
property: PropertyName;
|
|
35
35
|
}
|
|
@@ -69,7 +69,7 @@ interface RandomSampleReducer extends GroupByReducer<AggregateGroupByReducers.RA
|
|
|
69
69
|
property: PropertyName;
|
|
70
70
|
sampleSize: number;
|
|
71
71
|
}
|
|
72
|
-
|
|
72
|
+
type GroupByReducers = CountReducer | CountDistinctReducer | CountDistinctishReducer | SumReducer | MinReducer | MaxReducer | AvgReducer | StdDevReducer | QuantileReducer | ToListReducer | FirstValueReducer | RandomSampleReducer;
|
|
73
73
|
interface GroupByStep extends AggregateStep<AggregateSteps.GROUPBY> {
|
|
74
74
|
properties?: PropertyName | Array<PropertyName>;
|
|
75
75
|
REDUCE: GroupByReducers | Array<GroupByReducers>;
|
|
@@ -89,7 +89,7 @@ interface LimitStep extends AggregateStep<AggregateSteps.LIMIT> {
|
|
|
89
89
|
interface FilterStep extends AggregateStep<AggregateSteps.FILTER> {
|
|
90
90
|
expression: string;
|
|
91
91
|
}
|
|
92
|
-
|
|
92
|
+
type LoadField = PropertyName | {
|
|
93
93
|
identifier: PropertyName;
|
|
94
94
|
AS?: string;
|
|
95
95
|
};
|
|
@@ -104,7 +104,7 @@ export declare const FIRST_KEY_INDEX = 1;
|
|
|
104
104
|
export declare const IS_READ_ONLY = true;
|
|
105
105
|
export declare function transformArguments(index: string, query: string, options?: AggregateOptions): RedisCommandArguments;
|
|
106
106
|
export declare function pushAggregatehOptions(args: RedisCommandArguments, options?: AggregateOptions): RedisCommandArguments;
|
|
107
|
-
export
|
|
107
|
+
export type AggregateRawReply = [
|
|
108
108
|
total: number,
|
|
109
109
|
...results: Array<Array<RedisCommandArgument>>
|
|
110
110
|
];
|
|
@@ -4,7 +4,7 @@ interface AggregateWithCursorOptions extends AggregateOptions {
|
|
|
4
4
|
COUNT?: number;
|
|
5
5
|
}
|
|
6
6
|
export declare function transformArguments(index: string, query: string, options?: AggregateWithCursorOptions): import("@redis/client/dist/lib/commands").RedisCommandArguments;
|
|
7
|
-
|
|
7
|
+
type AggregateWithCursorRawReply = [
|
|
8
8
|
result: AggregateRawReply,
|
|
9
9
|
cursor: number
|
|
10
10
|
];
|
package/dist/commands/INFO.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ import { AggregateOptions, AggregateRawReply } from './AGGREGATE';
|
|
|
2
2
|
import { ProfileOptions, ProfileRawReply, ProfileReply } from '.';
|
|
3
3
|
export declare const IS_READ_ONLY = true;
|
|
4
4
|
export declare function transformArguments(index: string, query: string, options?: ProfileOptions & AggregateOptions): Array<string>;
|
|
5
|
-
|
|
5
|
+
type ProfileAggeregateRawReply = ProfileRawReply<AggregateRawReply>;
|
|
6
6
|
export declare function transformReply(reply: ProfileAggeregateRawReply): ProfileReply;
|
|
7
7
|
export {};
|
|
@@ -3,6 +3,6 @@ import { ProfileOptions, ProfileRawReply, ProfileReply } from '.';
|
|
|
3
3
|
import { RedisCommandArguments } from '@redis/client/dist/lib/commands';
|
|
4
4
|
export declare const IS_READ_ONLY = true;
|
|
5
5
|
export declare function transformArguments(index: string, query: string, options?: ProfileOptions & SearchOptions): RedisCommandArguments;
|
|
6
|
-
|
|
6
|
+
type ProfileSearchRawReply = ProfileRawReply<SearchRawReply>;
|
|
7
7
|
export declare function transformReply(reply: ProfileSearchRawReply): ProfileReply;
|
|
8
8
|
export {};
|
|
@@ -36,5 +36,5 @@ export interface SearchOptions {
|
|
|
36
36
|
DIALECT?: number;
|
|
37
37
|
}
|
|
38
38
|
export declare function transformArguments(index: string, query: string, options?: SearchOptions): RedisCommandArguments;
|
|
39
|
-
export
|
|
39
|
+
export type SearchRawReply = Array<any>;
|
|
40
40
|
export declare function transformReply(reply: SearchRawReply): SearchReply;
|
package/dist/commands/SEARCH.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.transformReply = exports.transformArguments = exports.IS_READ_ONLY = exports.FIRST_KEY_INDEX = void 0;
|
|
4
|
-
const generic_transformers_1 = require("@redis/client/dist/lib/commands/generic-transformers");
|
|
5
4
|
const _1 = require(".");
|
|
6
5
|
exports.FIRST_KEY_INDEX = 1;
|
|
7
6
|
exports.IS_READ_ONLY = true;
|
|
@@ -11,13 +10,11 @@ function transformArguments(index, query, options) {
|
|
|
11
10
|
exports.transformArguments = transformArguments;
|
|
12
11
|
function transformReply(reply) {
|
|
13
12
|
const documents = [];
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
let i = 1;
|
|
14
|
+
while (i < reply.length) {
|
|
16
15
|
documents.push({
|
|
17
|
-
id: reply[i],
|
|
18
|
-
value:
|
|
19
|
-
JSON.parse(tuples[1]) :
|
|
20
|
-
(0, generic_transformers_1.transformTuplesReply)(tuples)
|
|
16
|
+
id: reply[i++],
|
|
17
|
+
value: documentValue(reply[i++])
|
|
21
18
|
});
|
|
22
19
|
}
|
|
23
20
|
return {
|
|
@@ -26,3 +23,23 @@ function transformReply(reply) {
|
|
|
26
23
|
};
|
|
27
24
|
}
|
|
28
25
|
exports.transformReply = transformReply;
|
|
26
|
+
function documentValue(tuples) {
|
|
27
|
+
const message = Object.create(null);
|
|
28
|
+
if (tuples === undefined)
|
|
29
|
+
return message;
|
|
30
|
+
let i = 0;
|
|
31
|
+
while (i < tuples.length) {
|
|
32
|
+
const key = tuples[i++], value = tuples[i++];
|
|
33
|
+
if (key === '$') { // might be a JSON reply
|
|
34
|
+
try {
|
|
35
|
+
Object.assign(message, JSON.parse(value));
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
// set as a regular property if not a valid JSON
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
message[key] = value;
|
|
43
|
+
}
|
|
44
|
+
return message;
|
|
45
|
+
}
|
|
@@ -8,12 +8,12 @@ interface SpellCheckOptions {
|
|
|
8
8
|
DIALECT?: number;
|
|
9
9
|
}
|
|
10
10
|
export declare function transformArguments(index: string, query: string, options?: SpellCheckOptions): Array<string>;
|
|
11
|
-
|
|
11
|
+
type SpellCheckRawReply = Array<[
|
|
12
12
|
_: string,
|
|
13
13
|
term: string,
|
|
14
14
|
suggestions: Array<[score: string, suggestion: string]>
|
|
15
15
|
]>;
|
|
16
|
-
|
|
16
|
+
type SpellCheckReply = Array<{
|
|
17
17
|
term: string;
|
|
18
18
|
suggestions: Array<{
|
|
19
19
|
score: number;
|
|
@@ -3,5 +3,5 @@ import { SuggestionWithPayload } from './SUGGET_WITHPAYLOADS';
|
|
|
3
3
|
import { SuggestionWithScores } from './SUGGET_WITHSCORES';
|
|
4
4
|
export { IS_READ_ONLY } from './SUGGET';
|
|
5
5
|
export declare function transformArguments(key: string, prefix: string, options?: SugGetOptions): Array<string>;
|
|
6
|
-
|
|
6
|
+
type SuggestionWithScoresAndPayloads = SuggestionWithScores & SuggestionWithPayload;
|
|
7
7
|
export declare function transformReply(rawReply: Array<string | null> | null): Array<SuggestionWithScoresAndPayloads> | null;
|
package/dist/commands/index.d.ts
CHANGED
|
@@ -129,9 +129,9 @@ export declare enum RedisSearchLanguages {
|
|
|
129
129
|
TURKISH = "Turkish",
|
|
130
130
|
CHINESE = "Chinese"
|
|
131
131
|
}
|
|
132
|
-
export
|
|
133
|
-
export
|
|
134
|
-
BY:
|
|
132
|
+
export type PropertyName = `${'@' | '$.'}${string}`;
|
|
133
|
+
export type SortByProperty = string | {
|
|
134
|
+
BY: string;
|
|
135
135
|
DIRECTION?: 'ASC' | 'DESC';
|
|
136
136
|
};
|
|
137
137
|
export declare function pushSortByProperty(args: RedisCommandArguments, sortBy: SortByProperty): void;
|
|
@@ -144,11 +144,11 @@ export declare enum SchemaFieldTypes {
|
|
|
144
144
|
TAG = "TAG",
|
|
145
145
|
VECTOR = "VECTOR"
|
|
146
146
|
}
|
|
147
|
-
|
|
147
|
+
type CreateSchemaField<T extends SchemaFieldTypes, E = Record<PropertyKey, unknown>> = T | ({
|
|
148
148
|
type: T;
|
|
149
149
|
AS?: string;
|
|
150
150
|
} & E);
|
|
151
|
-
|
|
151
|
+
type CreateSchemaCommonField<T extends SchemaFieldTypes, E = Record<PropertyKey, unknown>> = CreateSchemaField<T, ({
|
|
152
152
|
SORTABLE?: true | 'UNF';
|
|
153
153
|
NOINDEX?: true;
|
|
154
154
|
} & E)>;
|
|
@@ -158,15 +158,15 @@ export declare enum SchemaTextFieldPhonetics {
|
|
|
158
158
|
FM_PT = "dm:pt",
|
|
159
159
|
DM_ES = "dm:es"
|
|
160
160
|
}
|
|
161
|
-
|
|
161
|
+
type CreateSchemaTextField = CreateSchemaCommonField<SchemaFieldTypes.TEXT, {
|
|
162
162
|
NOSTEM?: true;
|
|
163
163
|
WEIGHT?: number;
|
|
164
164
|
PHONETIC?: SchemaTextFieldPhonetics;
|
|
165
165
|
WITHSUFFIXTRIE?: boolean;
|
|
166
166
|
}>;
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
167
|
+
type CreateSchemaNumericField = CreateSchemaCommonField<SchemaFieldTypes.NUMERIC>;
|
|
168
|
+
type CreateSchemaGeoField = CreateSchemaCommonField<SchemaFieldTypes.GEO>;
|
|
169
|
+
type CreateSchemaTagField = CreateSchemaCommonField<SchemaFieldTypes.TAG, {
|
|
170
170
|
SEPARATOR?: string;
|
|
171
171
|
CASESENSITIVE?: true;
|
|
172
172
|
WITHSUFFIXTRIE?: boolean;
|
|
@@ -175,17 +175,17 @@ export declare enum VectorAlgorithms {
|
|
|
175
175
|
FLAT = "FLAT",
|
|
176
176
|
HNSW = "HNSW"
|
|
177
177
|
}
|
|
178
|
-
|
|
178
|
+
type CreateSchemaVectorField<T extends VectorAlgorithms, A extends Record<string, unknown>> = CreateSchemaField<SchemaFieldTypes.VECTOR, {
|
|
179
179
|
ALGORITHM: T;
|
|
180
180
|
TYPE: string;
|
|
181
181
|
DIM: number;
|
|
182
182
|
DISTANCE_METRIC: 'L2' | 'IP' | 'COSINE';
|
|
183
183
|
INITIAL_CAP?: number;
|
|
184
184
|
} & A>;
|
|
185
|
-
|
|
185
|
+
type CreateSchemaFlatVectorField = CreateSchemaVectorField<VectorAlgorithms.FLAT, {
|
|
186
186
|
BLOCK_SIZE?: number;
|
|
187
187
|
}>;
|
|
188
|
-
|
|
188
|
+
type CreateSchemaHNSWVectorField = CreateSchemaVectorField<VectorAlgorithms.HNSW, {
|
|
189
189
|
M?: number;
|
|
190
190
|
EF_CONSTRUCTION?: number;
|
|
191
191
|
EF_RUNTIME?: number;
|
|
@@ -194,7 +194,7 @@ export interface RediSearchSchema {
|
|
|
194
194
|
[field: string]: CreateSchemaTextField | CreateSchemaNumericField | CreateSchemaGeoField | CreateSchemaTagField | CreateSchemaFlatVectorField | CreateSchemaHNSWVectorField;
|
|
195
195
|
}
|
|
196
196
|
export declare function pushSchema(args: RedisCommandArguments, schema: RediSearchSchema): void;
|
|
197
|
-
export
|
|
197
|
+
export type Params = Record<string, RedisCommandArgument | number>;
|
|
198
198
|
export declare function pushParamsArgs(args: RedisCommandArguments, params?: Params): RedisCommandArguments;
|
|
199
199
|
export declare function pushSearchOptions(args: RedisCommandArguments, options?: SearchOptions): RedisCommandArguments;
|
|
200
200
|
interface SearchDocumentValue {
|
|
@@ -210,7 +210,7 @@ export interface SearchReply {
|
|
|
210
210
|
export interface ProfileOptions {
|
|
211
211
|
LIMITED?: true;
|
|
212
212
|
}
|
|
213
|
-
export
|
|
213
|
+
export type ProfileRawReply<T> = [
|
|
214
214
|
results: T,
|
|
215
215
|
profile: [
|
|
216
216
|
_: string,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redis/search",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
|
20
20
|
"@redis/test-utils": "*",
|
|
21
|
-
"@types/node": "^18.
|
|
21
|
+
"@types/node": "^18.11.18",
|
|
22
22
|
"nyc": "^15.1.0",
|
|
23
|
-
"release-it": "^15.
|
|
23
|
+
"release-it": "^15.6.0",
|
|
24
24
|
"source-map-support": "^0.5.21",
|
|
25
25
|
"ts-node": "^10.9.1",
|
|
26
|
-
"typedoc": "^0.23.
|
|
27
|
-
"typescript": "^4.
|
|
26
|
+
"typedoc": "^0.23.24",
|
|
27
|
+
"typescript": "^4.9.4"
|
|
28
28
|
}
|
|
29
29
|
}
|