英文:
redis FT.SEARCH on tag type fields and special characters value
问题
在Redis索引中,我插入了以下条目:
id:contact:dacd5f23-e493-4db1-b1b9-74a6783b41b5
FirstName:Dan
LastName:White
website:https://dan.white.com
"website"字段的类型是"tag",我想要精确匹配,但我无法使其正常工作。如果我不转义":",我会收到语法错误。当我用"\:"进行转义时,语法错误消失了,但我没有得到任何结果。
我的精确搜索查询如下:
FT.SEARCH contact "@website:{https\://dan.white.com}"
我运行下一个查询时没有遇到任何问题,并且收到了相应的结果:
FT.SEARCH contact "@FirstName:{Dan}"
英文:
On a Redis index, I inserted the following entry:
id:contact:dacd5f23-e493-4db1-b1b9-74a6783b41b5
FirstName:Dan
LastName:White
website:https://dan.white.com
The "website" field is of type "tag," and I want an exact match, but I'm unable to make it work. If I don't escape the ":", I receive a syntax error. When I escape it with "\:", the syntax error disappears, but I don't get any results.
My exact search query is:
FT.SEARCH contact "@website:{https\\://dan.white.com}"
I don't encounter any problems running the next query, and I receive the appropriate results:
FT.SEARCH contact "@FirstName:{Dan}"
答案1
得分: 1
TAG查询中的字符串经过文本过滤器运行,该过滤器会剥离标点符号、停用词等内容。为使其正常工作,您需要转义所有类型的内容,包括有时空格。请尝试以下方法:
127.0.0.1:6379> FT.SEARCH contact ""@website:{https\:\/\/dan\.white\.com}""
当然,如果这是代码中的字符串,您还需要转义反斜杠。
英文:
The strings in TAG queries are run through text filters which strip out punctuation, stop words, and stuff like that. You need to escape all sorts of stuff to make it work, including sometimes spaces. Try this:
127.0.0.1:6379> FT.SEARCH contact "@website:{https\:\/\/dan\.white\.com}"
Of course, if this is a string in code, you'll need to escape the backslashes as well.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论