简体   繁体   中英

How to the @ symbol in RediSearch?

I'm using the modules RedisJSON and RediSearch together to perform search queries on JSON data. Given a json list like this:

{"email": "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

How can I select with the value "test1@example.com"?

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 .

With an index where there's an email field stored as a TAG you can do a search like this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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