NicolasS
NicolasS

Reputation: 11

Redis Python execute_command Redisearch

I am using python 3.6 in order to add some documents on a redis server ! So I use the command : execute_command with the module Redis.

In my exemple I want to add metadata to a redisearch document with :

c = 'FT.ADD idx doc 1 REPLACE FIELDS parameter'  + ' ' + a 

r.execute_command(c)

a is a str data. So i want to add parameter : a in the document doc. where 'a' is TEXT.

But when there is a space in 'str a', execute _command consider that it is a next argument even if I put quotes (" or ') on each side ...

For exemple : If a = '"Test Test"', I will just find "\"Test" on the redis server ...

How can I deal with this ?

Thanks for your help.

Upvotes: 1

Views: 2485

Answers (1)

yangbodong
yangbodong

Reputation: 75

try this:

r.execute_command('FT.ADD', 'idx', 'doc', 1, 'REPLACE', 'FIELDS', 'parameter', 'a');

Upvotes: 1

Related Questions