简体   繁体   English

Redis Python execute_command Redissearch

[英]Redis Python execute_command Redisearch

I am using python 3.6 in order to add some documents on a redis server !我正在使用 python 3.6 以便在 redis 服务器上添加一些文档! So I use the command : execute_command with the module Redis.所以我使用命令: execute_command和模块Redis。

In my exemple I want to add metadata to a redisearch document with :在我的示例中,我想将元数据添加到 redisearch 文档中:

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

r.execute_command(c)

a is a str data. a 是一个 str 数据。 So i want to add parameter : a in the document doc.所以我想在文档doc中添加参数:a。 where 'a' is TEXT.其中“a”是文本。

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 ...但是当'str a'有空格时,执行 _command 认为它是下一个参数,即使我在每一边都加上引号("') ...

For exemple : If a = '"Test Test"' , I will just find "\\"Test" on the redis server ...例如:如果a = '"Test Test"' ,我只会在 redis 服务器上找到"\\"Test" ...

How can I deal with this ?我该如何处理?

Thanks for your help.谢谢你的帮助。

试试这个:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM