@@ -49,14 +49,18 @@ export class RedisearchService {
49
49
50
50
try {
51
51
const client : RedisClient = await this . databaseClientFactory . getOrCreateClient ( clientMetadata ) ;
52
- const nodes = this . getShards ( client ) as RedisClient [ ] ;
52
+ const nodes = await this . getShards ( client ) as RedisClient [ ] ;
53
53
54
54
const res = await Promise . all ( nodes . map ( async ( node ) => node . sendCommand (
55
55
[ 'FT._LIST' ] ,
56
56
) ) ) ;
57
57
58
58
return plainToClass ( ListRedisearchIndexesResponse , {
59
- indexes : ( uniq ( [ ] . concat ( ...res ) ) ) . map ( ( idx ) => Buffer . from ( idx ) ) ,
59
+ indexes : (
60
+ uniq (
61
+ ( [ ] . concat ( ...res ) ) . map ( ( idx ) => idx . toString ( 'hex' ) ) ,
62
+ )
63
+ ) . map ( ( idx ) => Buffer . from ( idx , 'hex' ) ) ,
60
64
} ) ;
61
65
} catch ( e ) {
62
66
this . logger . error ( 'Failed to get redisearch indexes' , e ) ;
@@ -100,7 +104,7 @@ export class RedisearchService {
100
104
}
101
105
}
102
106
103
- const nodes = this . getShards ( client ) as RedisClient [ ] ;
107
+ const nodes = await this . getShards ( client ) as RedisClient [ ] ;
104
108
105
109
const commandArgs : any [ ] = [
106
110
index , 'ON' , type ,
@@ -121,7 +125,7 @@ export class RedisearchService {
121
125
...commandArgs ,
122
126
] , { replyEncoding : 'utf8' } ) ;
123
127
} catch ( e ) {
124
- if ( ! e . message . includes ( 'MOVED' ) ) {
128
+ if ( ! e . message . includes ( 'MOVED' ) && ! e . message . includes ( 'already exists' ) ) {
125
129
throw e ;
126
130
}
127
131
}
@@ -228,7 +232,7 @@ export class RedisearchService {
228
232
* @param client
229
233
* @private
230
234
*/
231
- private getShards ( client : RedisClient ) : Promise < RedisClient [ ] > | RedisClient [ ] {
235
+ private async getShards ( client : RedisClient ) : Promise < RedisClient [ ] > {
232
236
if ( client . getConnectionType ( ) === RedisClientConnectionType . CLUSTER ) {
233
237
return client . nodes ( RedisClientNodeRole . PRIMARY ) ;
234
238
}
0 commit comments