@redis/search 1.1.2 → 1.1.4
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 +4 -4
- package/dist/commands/AGGREGATE.d.ts +1 -0
- package/dist/commands/AGGREGATE.js +5 -2
- package/dist/commands/CURSOR_READ.d.ts +4 -1
- package/dist/commands/CURSOR_READ.js +6 -2
- package/dist/commands/SEARCH.d.ts +1 -0
- package/dist/commands/SEARCH_NOCONTENT.d.ts +10 -0
- package/dist/commands/SEARCH_NOCONTENT.js +18 -0
- package/dist/commands/index.d.ts +3 -0
- package/dist/commands/index.js +10 -4
- package/package.json +18 -6
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ For complete examples, see [`search-hashes.js`](https://github.com/redis/node-re
|
|
|
12
12
|
|
|
13
13
|
#### Creating an Index
|
|
14
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://
|
|
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://redis.io/commands/ft.create) 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
16
|
|
|
17
17
|
```javascript
|
|
18
18
|
await client.ft.create('idx:animals', {
|
|
@@ -28,11 +28,11 @@ await client.ft.create('idx:animals', {
|
|
|
28
28
|
});
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
See the [`FT.CREATE` documentation](https://
|
|
31
|
+
See the [`FT.CREATE` documentation](https://redis.io/commands/ft.create/#description) for information about the different field types and additional options.
|
|
32
32
|
|
|
33
33
|
#### Querying the Index
|
|
34
34
|
|
|
35
|
-
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://
|
|
35
|
+
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://redis.io/commands/ft.search) and the [query syntax reference](https://redis.io/docs/interact/search-and-query/query) for more information.
|
|
36
36
|
|
|
37
37
|
Let's write a query to find all the animals where the `species` field has the value `dog`:
|
|
38
38
|
|
|
@@ -112,7 +112,7 @@ Note that we're using JSON Path to specify where the fields to index are in our
|
|
|
112
112
|
|
|
113
113
|
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...
|
|
114
114
|
|
|
115
|
-
We'll use the [RediSearch query language](https://
|
|
115
|
+
We'll use the [RediSearch query language](https://redis.io/docs/interact/search-and-query/query) and [`FT.SEARCH`](https://redis.io/commands/ft.search) command. Here's a query to find users under the age of 30:
|
|
116
116
|
|
|
117
117
|
```javascript
|
|
118
118
|
await client.ft.search('idx:users', '@age:[0 30]');
|
|
@@ -99,6 +99,7 @@ export interface AggregateOptions {
|
|
|
99
99
|
STEPS?: Array<GroupByStep | SortStep | ApplyStep | LimitStep | FilterStep>;
|
|
100
100
|
PARAMS?: Params;
|
|
101
101
|
DIALECT?: number;
|
|
102
|
+
TIMEOUT?: number;
|
|
102
103
|
}
|
|
103
104
|
export declare const FIRST_KEY_INDEX = 1;
|
|
104
105
|
export declare const IS_READ_ONLY = true;
|
|
@@ -10,7 +10,7 @@ var AggregateSteps;
|
|
|
10
10
|
AggregateSteps["APPLY"] = "APPLY";
|
|
11
11
|
AggregateSteps["LIMIT"] = "LIMIT";
|
|
12
12
|
AggregateSteps["FILTER"] = "FILTER";
|
|
13
|
-
})(AggregateSteps
|
|
13
|
+
})(AggregateSteps || (exports.AggregateSteps = AggregateSteps = {}));
|
|
14
14
|
var AggregateGroupByReducers;
|
|
15
15
|
(function (AggregateGroupByReducers) {
|
|
16
16
|
AggregateGroupByReducers["COUNT"] = "COUNT";
|
|
@@ -26,7 +26,7 @@ var AggregateGroupByReducers;
|
|
|
26
26
|
AggregateGroupByReducers["TO_LIST"] = "TOLIST";
|
|
27
27
|
AggregateGroupByReducers["FIRST_VALUE"] = "FIRST_VALUE";
|
|
28
28
|
AggregateGroupByReducers["RANDOM_SAMPLE"] = "RANDOM_SAMPLE";
|
|
29
|
-
})(AggregateGroupByReducers
|
|
29
|
+
})(AggregateGroupByReducers || (exports.AggregateGroupByReducers = AggregateGroupByReducers = {}));
|
|
30
30
|
exports.FIRST_KEY_INDEX = 1;
|
|
31
31
|
exports.IS_READ_ONLY = true;
|
|
32
32
|
function transformArguments(index, query, options) {
|
|
@@ -92,6 +92,9 @@ function pushAggregatehOptions(args, options) {
|
|
|
92
92
|
if (options?.DIALECT) {
|
|
93
93
|
args.push('DIALECT', options.DIALECT.toString());
|
|
94
94
|
}
|
|
95
|
+
if (options?.TIMEOUT !== undefined) {
|
|
96
|
+
args.push('TIMEOUT', options.TIMEOUT.toString());
|
|
97
|
+
}
|
|
95
98
|
return args;
|
|
96
99
|
}
|
|
97
100
|
exports.pushAggregatehOptions = pushAggregatehOptions;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands';
|
|
2
2
|
export declare const FIRST_KEY_INDEX = 1;
|
|
3
3
|
export declare const IS_READ_ONLY = true;
|
|
4
|
-
|
|
4
|
+
interface CursorReadOptions {
|
|
5
|
+
COUNT?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function transformArguments(index: RedisCommandArgument, cursor: number, options?: CursorReadOptions): RedisCommandArguments;
|
|
5
8
|
export { transformReply } from './AGGREGATE_WITHCURSOR';
|
|
@@ -3,13 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.transformReply = exports.transformArguments = exports.IS_READ_ONLY = exports.FIRST_KEY_INDEX = void 0;
|
|
4
4
|
exports.FIRST_KEY_INDEX = 1;
|
|
5
5
|
exports.IS_READ_ONLY = true;
|
|
6
|
-
function transformArguments(index, cursor) {
|
|
7
|
-
|
|
6
|
+
function transformArguments(index, cursor, options) {
|
|
7
|
+
const args = [
|
|
8
8
|
'FT.CURSOR',
|
|
9
9
|
'READ',
|
|
10
10
|
index,
|
|
11
11
|
cursor.toString()
|
|
12
12
|
];
|
|
13
|
+
if (options?.COUNT) {
|
|
14
|
+
args.push('COUNT', options.COUNT.toString());
|
|
15
|
+
}
|
|
16
|
+
return args;
|
|
13
17
|
}
|
|
14
18
|
exports.transformArguments = transformArguments;
|
|
15
19
|
var AGGREGATE_WITHCURSOR_1 = require("./AGGREGATE_WITHCURSOR");
|
|
@@ -34,6 +34,7 @@ export interface SearchOptions {
|
|
|
34
34
|
};
|
|
35
35
|
PARAMS?: Params;
|
|
36
36
|
DIALECT?: number;
|
|
37
|
+
TIMEOUT?: number;
|
|
37
38
|
}
|
|
38
39
|
export declare function transformArguments(index: string, query: string, options?: SearchOptions): RedisCommandArguments;
|
|
39
40
|
export type SearchRawReply = Array<any>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RedisCommandArguments } from "@redis/client/dist/lib/commands";
|
|
2
|
+
import { SearchOptions, SearchRawReply } from "./SEARCH";
|
|
3
|
+
export declare const FIRST_KEY_INDEX = 1;
|
|
4
|
+
export declare const IS_READ_ONLY = true;
|
|
5
|
+
export declare function transformArguments(index: string, query: string, options?: SearchOptions): RedisCommandArguments;
|
|
6
|
+
export interface SearchNoContentReply {
|
|
7
|
+
total: number;
|
|
8
|
+
documents: Array<string>;
|
|
9
|
+
}
|
|
10
|
+
export declare function transformReply(reply: SearchRawReply): SearchNoContentReply;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transformReply = exports.transformArguments = exports.IS_READ_ONLY = exports.FIRST_KEY_INDEX = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
exports.FIRST_KEY_INDEX = 1;
|
|
6
|
+
exports.IS_READ_ONLY = true;
|
|
7
|
+
function transformArguments(index, query, options) {
|
|
8
|
+
return (0, _1.pushSearchOptions)(['FT.SEARCH', index, query, 'NOCONTENT'], options);
|
|
9
|
+
}
|
|
10
|
+
exports.transformArguments = transformArguments;
|
|
11
|
+
;
|
|
12
|
+
function transformReply(reply) {
|
|
13
|
+
return {
|
|
14
|
+
total: reply[0],
|
|
15
|
+
documents: reply.slice(1)
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
exports.transformReply = transformReply;
|
package/dist/commands/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ import * as INFO from './INFO';
|
|
|
20
20
|
import * as PROFILESEARCH from './PROFILE_SEARCH';
|
|
21
21
|
import * as PROFILEAGGREGATE from './PROFILE_AGGREGATE';
|
|
22
22
|
import * as SEARCH from './SEARCH';
|
|
23
|
+
import * as SEARCH_NOCONTENT from './SEARCH_NOCONTENT';
|
|
23
24
|
import * as SPELLCHECK from './SPELLCHECK';
|
|
24
25
|
import * as SUGADD from './SUGADD';
|
|
25
26
|
import * as SUGDEL from './SUGDEL';
|
|
@@ -78,6 +79,8 @@ declare const _default: {
|
|
|
78
79
|
profileAggregate: typeof PROFILEAGGREGATE;
|
|
79
80
|
SEARCH: typeof SEARCH;
|
|
80
81
|
search: typeof SEARCH;
|
|
82
|
+
SEARCH_NOCONTENT: typeof SEARCH_NOCONTENT;
|
|
83
|
+
searchNoContent: typeof SEARCH_NOCONTENT;
|
|
81
84
|
SPELLCHECK: typeof SPELLCHECK;
|
|
82
85
|
spellCheck: typeof SPELLCHECK;
|
|
83
86
|
SUGADD: typeof SUGADD;
|
package/dist/commands/index.js
CHANGED
|
@@ -23,6 +23,7 @@ const INFO = require("./INFO");
|
|
|
23
23
|
const PROFILESEARCH = require("./PROFILE_SEARCH");
|
|
24
24
|
const PROFILEAGGREGATE = require("./PROFILE_AGGREGATE");
|
|
25
25
|
const SEARCH = require("./SEARCH");
|
|
26
|
+
const SEARCH_NOCONTENT = require("./SEARCH_NOCONTENT");
|
|
26
27
|
const SPELLCHECK = require("./SPELLCHECK");
|
|
27
28
|
const SUGADD = require("./SUGADD");
|
|
28
29
|
const SUGDEL = require("./SUGDEL");
|
|
@@ -80,6 +81,8 @@ exports.default = {
|
|
|
80
81
|
profileAggregate: PROFILEAGGREGATE,
|
|
81
82
|
SEARCH,
|
|
82
83
|
search: SEARCH,
|
|
84
|
+
SEARCH_NOCONTENT,
|
|
85
|
+
searchNoContent: SEARCH_NOCONTENT,
|
|
83
86
|
SPELLCHECK,
|
|
84
87
|
spellCheck: SPELLCHECK,
|
|
85
88
|
SUGADD,
|
|
@@ -130,7 +133,7 @@ var RedisSearchLanguages;
|
|
|
130
133
|
RedisSearchLanguages["TAMIL"] = "Tamil";
|
|
131
134
|
RedisSearchLanguages["TURKISH"] = "Turkish";
|
|
132
135
|
RedisSearchLanguages["CHINESE"] = "Chinese";
|
|
133
|
-
})(RedisSearchLanguages
|
|
136
|
+
})(RedisSearchLanguages || (exports.RedisSearchLanguages = RedisSearchLanguages = {}));
|
|
134
137
|
function pushSortByProperty(args, sortBy) {
|
|
135
138
|
if (typeof sortBy === 'string') {
|
|
136
139
|
args.push(sortBy);
|
|
@@ -172,19 +175,19 @@ var SchemaFieldTypes;
|
|
|
172
175
|
SchemaFieldTypes["GEO"] = "GEO";
|
|
173
176
|
SchemaFieldTypes["TAG"] = "TAG";
|
|
174
177
|
SchemaFieldTypes["VECTOR"] = "VECTOR";
|
|
175
|
-
})(SchemaFieldTypes
|
|
178
|
+
})(SchemaFieldTypes || (exports.SchemaFieldTypes = SchemaFieldTypes = {}));
|
|
176
179
|
var SchemaTextFieldPhonetics;
|
|
177
180
|
(function (SchemaTextFieldPhonetics) {
|
|
178
181
|
SchemaTextFieldPhonetics["DM_EN"] = "dm:en";
|
|
179
182
|
SchemaTextFieldPhonetics["DM_FR"] = "dm:fr";
|
|
180
183
|
SchemaTextFieldPhonetics["FM_PT"] = "dm:pt";
|
|
181
184
|
SchemaTextFieldPhonetics["DM_ES"] = "dm:es";
|
|
182
|
-
})(SchemaTextFieldPhonetics
|
|
185
|
+
})(SchemaTextFieldPhonetics || (exports.SchemaTextFieldPhonetics = SchemaTextFieldPhonetics = {}));
|
|
183
186
|
var VectorAlgorithms;
|
|
184
187
|
(function (VectorAlgorithms) {
|
|
185
188
|
VectorAlgorithms["FLAT"] = "FLAT";
|
|
186
189
|
VectorAlgorithms["HNSW"] = "HNSW";
|
|
187
|
-
})(VectorAlgorithms
|
|
190
|
+
})(VectorAlgorithms || (exports.VectorAlgorithms = VectorAlgorithms = {}));
|
|
188
191
|
function pushSchema(args, schema) {
|
|
189
192
|
for (const [field, fieldOptions] of Object.entries(schema)) {
|
|
190
193
|
args.push(field);
|
|
@@ -362,6 +365,9 @@ function pushSearchOptions(args, options) {
|
|
|
362
365
|
if (options?.RETURN?.length === 0) {
|
|
363
366
|
args.preserve = true;
|
|
364
367
|
}
|
|
368
|
+
if (options?.TIMEOUT !== undefined) {
|
|
369
|
+
args.push('TIMEOUT', options.TIMEOUT.toString());
|
|
370
|
+
}
|
|
365
371
|
return args;
|
|
366
372
|
}
|
|
367
373
|
exports.pushSearchOptions = pushSearchOptions;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redis/search",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -18,12 +18,24 @@
|
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
|
20
20
|
"@redis/test-utils": "*",
|
|
21
|
-
"@types/node": "^
|
|
21
|
+
"@types/node": "^20.6.2",
|
|
22
22
|
"nyc": "^15.1.0",
|
|
23
|
-
"release-it": "^
|
|
23
|
+
"release-it": "^16.1.5",
|
|
24
24
|
"source-map-support": "^0.5.21",
|
|
25
25
|
"ts-node": "^10.9.1",
|
|
26
|
-
"typedoc": "^0.
|
|
27
|
-
"typescript": "^
|
|
28
|
-
}
|
|
26
|
+
"typedoc": "^0.25.1",
|
|
27
|
+
"typescript": "^5.2.2"
|
|
28
|
+
},
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git://github.com/redis/node-redis.git"
|
|
32
|
+
},
|
|
33
|
+
"bugs": {
|
|
34
|
+
"url": "https://github.com/redis/node-redis/issues"
|
|
35
|
+
},
|
|
36
|
+
"homepage": "https://github.com/redis/node-redis/tree/master/packages/search",
|
|
37
|
+
"keywords": [
|
|
38
|
+
"redis",
|
|
39
|
+
"RediSearch"
|
|
40
|
+
]
|
|
29
41
|
}
|