File tree Expand file tree Collapse file tree 4 files changed +15
-8
lines changed
packages/search/lib/commands Expand file tree Collapse file tree 4 files changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ export function transformArguments(
99 query : string ,
1010 options ?: ProfileOptions & SearchOptions
1111) : RedisCommandArguments {
12- const args = [ 'FT.PROFILE' , index , 'SEARCH' ] ;
12+ let args : RedisCommandArguments = [ 'FT.PROFILE' , index , 'SEARCH' ] ;
1313
1414 if ( options ?. LIMITED ) {
1515 args . push ( 'LIMITED' ) ;
@@ -21,9 +21,9 @@ export function transformArguments(
2121
2222type ProfileSearchRawReply = ProfileRawReply < SearchRawReply > ;
2323
24- export function transformReply ( reply : ProfileSearchRawReply ) : ProfileReply {
24+ export function transformReply ( reply : ProfileSearchRawReply , withoutDocuments : boolean ) : ProfileReply {
2525 return {
26- results : transformSearchReply ( reply [ 0 ] ) ,
26+ results : transformSearchReply ( reply [ 0 ] , withoutDocuments ) ,
2727 profile : transformProfile ( reply [ 1 ] )
2828 } ;
2929}
Original file line number Diff line number Diff line change @@ -267,18 +267,22 @@ describe('SEARCH', () => {
267267 client . ft . create ( 'index' , {
268268 field : SchemaFieldTypes . NUMERIC
269269 } ) ,
270- client . hSet ( '1' , 'field' , '1' )
270+ client . hSet ( '1' , 'field' , '1' ) ,
271+ client . hSet ( '2' , 'field' , '2' )
271272 ] ) ;
272273
273274 assert . deepEqual (
274275 await client . ft . search ( 'index' , '*' , {
275276 RETURN : [ ]
276277 } ) ,
277278 {
278- total : 1 ,
279+ total : 2 ,
279280 documents : [ {
280281 id : '1' ,
281282 value : Object . create ( null )
283+ } , {
284+ id : '2' ,
285+ value : Object . create ( null )
282286 } ]
283287 }
284288 ) ;
Original file line number Diff line number Diff line change @@ -70,13 +70,13 @@ export function transformArguments(
7070
7171export type SearchRawReply = Array < any > ;
7272
73- export function transformReply ( reply : SearchRawReply ) : SearchReply {
73+ export function transformReply ( reply : SearchRawReply , withoutDocuments : boolean ) : SearchReply {
7474 const documents = [ ] ;
7575 let i = 1 ;
7676 while ( i < reply . length ) {
7777 documents . push ( {
7878 id : reply [ i ++ ] ,
79- value : documentValue ( reply [ i ++ ] )
79+ value : withoutDocuments ? Object . create ( null ) : documentValue ( reply [ i ++ ] )
8080 } ) ;
8181 }
8282
@@ -88,7 +88,6 @@ export function transformReply(reply: SearchRawReply): SearchReply {
8888
8989function documentValue ( tuples : any ) {
9090 const message = Object . create ( null ) ;
91- if ( tuples === undefined ) return message ;
9291
9392 let i = 0 ;
9493 while ( i < tuples . length ) {
Original file line number Diff line number Diff line change @@ -506,6 +506,10 @@ export function pushSearchOptions(
506506 args . push ( 'DIALECT' , options . DIALECT . toString ( ) ) ;
507507 }
508508
509+ if ( options ?. RETURN ?. length === 0 ) {
510+ args . preserve = true ;
511+ }
512+
509513 return args ;
510514}
511515
You can’t perform that action at this time.
0 commit comments