简体   繁体   English

如何在 RediSearch 中使用 @ 符号?

[英]How to the @ symbol in RediSearch?

I'm using the modules RedisJSON and RediSearch together to perform search queries on JSON data.我一起使用模块 RedisJSON 和 RediSearch 对 JSON 数据执行搜索查询。 Given a json list like this:给定一个 json 列表,如下所示:

{"email": "test1@example.com", "is_checked": 1} {“电子邮件”:“test1@example.com”,“is_checked”:1}

I do:我愿意:

FT.CREATE myidx ON JSON SCHEMA $.email AS email TAG
FT.SEARCH myidx "@email:'test1@example.com'"

but I got Syntax error但我得到了Syntax error

How can I select with the value "test1@example.com"?如何使用值为“test1@example.com”的 select?

You can escape special characters, like @, with a backslash:您可以使用反斜杠转义特殊字符,例如 @:

FT.SEARCH myidx "@email:'test1\@example.com'"

That should do the trick.这应该够了吧。

I just ran into this issue and the accepted answer didn't work for me, but I found a solution in this RediSearch issue .我刚遇到这个问题,接受的答案对我不起作用,但我在这个 RediSearch 问题中找到了解决方案。

With an index where there's an email field stored as a TAG you can do a search like this:使用存储为TAG的 email 字段的索引,您可以进行如下搜索:

FT.SEARCH myidx "@email:{ test1\\@example\\.com }"

With the @ and .使用@. characters escaped.字符转义。

Here are the docs for querying on TAG fields as well: https://redis.io/docs/stack/search/reference/tags/#querying-tag-fields以下是查询TAG字段的文档: https://redis.io/docs/stack/search/reference/tags/#querying-tag-fields

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

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