1

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.

3
  • Have you tried r.execute_command(['FT.ADD','idx','doc',1,'REPLACE','FIELDS', 'parameter',a]? Commented Dec 10, 2019 at 21:29
  • When I use it I have this error : DataError: Invalid input of type: 'list'. Convert to a byte, string or number first. Commented Dec 10, 2019 at 23:17
  • Did you try the github.com/RediSearch/redisearch-py Commented Dec 11, 2019 at 5:38

1 Answer 1

1

try this:

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.