思维狮身人面像词匹配

发布于 2025-01-05 23:59:04 字数 1206 浏览 6 评论 0 原文

我所拥有的数据是

[email protected] - 第一条记录 [email protected] -

我需要使用电子邮件地址进行搜索的第二条记录。我的网络应用程序中有论坛和用户索引。

第一种情况是

我在字符集表中保留了“@”符号,该符号工作正常,问题是例如如果搜索关键字为“[email protected]' 它给了我确切的结果,但如果我仅用户“测试”未找到结果。

第二种情况

如果我不会在字符集表中保留“@”符号。如果我使用 '[email protected]' 我会得到两个结果 结果

对于“测试”,我也得到了预期场景的

如果我使用整个电子邮件“[email protected]' - 我只需要获取第一条记录 如果我只使用'测试' - 我需要在普通mysql中获取两条记录,

例如“选择电子邮件类似于'%search-key%'的用户”

我使用以下代码来搜索

ThinkingSphinx.search params [:search_key], :星=> Regexp.new('\w+@*\w+', nil, 'u') (我不想将 '@' 视为分隔符)

请建议我可以通过以实现预期结果的任何选项。

谢谢 基兰

The data what i have is

[email protected] - first record
[email protected] - second record

I need to search using the email address. I have forums and users indexed in my web app.

First scenario

I kept the '@' symbol in the charset table which is working fine problem is for example if the search keyword as '[email protected]' it is giving me the exact result but if i user only 'test' no results found.

Second scenario

If i won't keep '@' symbol in the charset table. If the i use '[email protected]' i am getting both the results and for 'test' also i am getting both the results

Expected Scenario

If i use the entire email '[email protected]' - I need to get only first record
If i use only 'test' - I need to get both the records

In plain mysql something like "select users where email like '%search-key%'"

I use the following code for searching

ThinkingSphinx.search params[:search_key],:star => Regexp.new('\w+@*\w+', nil, 'u') (I don't want to treat '@' as the separator)

Please suggest me any options i can pass to achieve the expected result.

Thanks
Kiran

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

涙—继续流 2025-01-12 23:59:04

查看混合字符支持

http://sphinxsearch.com/docs/current。 html#conf-blend-chars

或者,如果您确实支持 [ email like '%search-key%'" ] 样式支持,也许是 min_infix_len。(在字符集表中保留 . 和 @)

Take a look at blended char support

http://sphinxsearch.com/docs/current.html#conf-blend-chars

Or if you really what [ email like '%search-key%'" ] style support maybe min_infix_len. (leaving . and @ in charset table)

ι不睡觉的鱼゛ 2025-01-12 23:59:04

要搜索完整的电子邮件,您可以使用短语搜索运算符。

http://sphinxsearch.com/docs/current.html#extended-syntax

因此,如果您可以将搜索查询确定为电子邮件,请使用“短语搜索”,否则请使用常规搜索。

To search for full email you could use Phrase Search operator.

http://sphinxsearch.com/docs/current.html#extended-syntax

So, if you could determine search query as email use "phrase search" otherwise use general search.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文