File tree 4 files changed +15
-8
lines changed
packages/search/lib/commands
4 files changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ export function transformArguments(
9
9
query : string ,
10
10
options ?: ProfileOptions & SearchOptions
11
11
) : RedisCommandArguments {
12
- const args = [ 'FT.PROFILE' , index , 'SEARCH' ] ;
12
+ let args : RedisCommandArguments = [ 'FT.PROFILE' , index , 'SEARCH' ] ;
13
13
14
14
if ( options ?. LIMITED ) {
15
15
args . push ( 'LIMITED' ) ;
@@ -21,9 +21,9 @@ export function transformArguments(
21
21
22
22
type ProfileSearchRawReply = ProfileRawReply < SearchRawReply > ;
23
23
24
- export function transformReply ( reply : ProfileSearchRawReply ) : ProfileReply {
24
+ export function transformReply ( reply : ProfileSearchRawReply , withoutDocuments : boolean ) : ProfileReply {
25
25
return {
26
- results : transformSearchReply ( reply [ 0 ] ) ,
26
+ results : transformSearchReply ( reply [ 0 ] , withoutDocuments ) ,
27
27
profile : transformProfile ( reply [ 1 ] )
28
28
} ;
29
29
}
Original file line number Diff line number Diff line change @@ -267,18 +267,22 @@ describe('SEARCH', () => {
267
267
client . ft . create ( 'index' , {
268
268
field : SchemaFieldTypes . NUMERIC
269
269
} ) ,
270
- client . hSet ( '1' , 'field' , '1' )
270
+ client . hSet ( '1' , 'field' , '1' ) ,
271
+ client . hSet ( '2' , 'field' , '2' )
271
272
] ) ;
272
273
273
274
assert . deepEqual (
274
275
await client . ft . search ( 'index' , '*' , {
275
276
RETURN : [ ]
276
277
} ) ,
277
278
{
278
- total : 1 ,
279
+ total : 2 ,
279
280
documents : [ {
280
281
id : '1' ,
281
282
value : Object . create ( null )
283
+ } , {
284
+ id : '2' ,
285
+ value : Object . create ( null )
282
286
} ]
283
287
}
284
288
) ;
Original file line number Diff line number Diff line change @@ -70,13 +70,13 @@ export function transformArguments(
70
70
71
71
export type SearchRawReply = Array < any > ;
72
72
73
- export function transformReply ( reply : SearchRawReply ) : SearchReply {
73
+ export function transformReply ( reply : SearchRawReply , withoutDocuments : boolean ) : SearchReply {
74
74
const documents = [ ] ;
75
75
let i = 1 ;
76
76
while ( i < reply . length ) {
77
77
documents . push ( {
78
78
id : reply [ i ++ ] ,
79
- value : documentValue ( reply [ i ++ ] )
79
+ value : withoutDocuments ? Object . create ( null ) : documentValue ( reply [ i ++ ] )
80
80
} ) ;
81
81
}
82
82
@@ -88,7 +88,6 @@ export function transformReply(reply: SearchRawReply): SearchReply {
88
88
89
89
function documentValue ( tuples : any ) {
90
90
const message = Object . create ( null ) ;
91
- if ( tuples === undefined ) return message ;
92
91
93
92
let i = 0 ;
94
93
while ( i < tuples . length ) {
Original file line number Diff line number Diff line change @@ -506,6 +506,10 @@ export function pushSearchOptions(
506
506
args . push ( 'DIALECT' , options . DIALECT . toString ( ) ) ;
507
507
}
508
508
509
+ if ( options ?. RETURN ?. length === 0 ) {
510
+ args . preserve = true ;
511
+ }
512
+
509
513
return args ;
510
514
}
511
515
You can’t perform that action at this time.
0 commit comments