MySQL MATCH-AGAINST 复数单词?
我想向我的网站添加搜索。我有一个视频游戏挑战数据库。每个挑战都有标题和描述,我希望至少能够搜索描述,但如果可能的话,两者都搜索。现在,我已经设置了表格,以便可以使用 MATCH() AGAINST(),但我遇到了单数或复数单词的问题。
例如,“assists”这个词出现在多个挑战中,但如果用户输入“assist”,他将不会得到任何东西。有什么方法可以添加该功能吗?我已经尝试了我能想到的一切,但到目前为止没有任何效果。
更新:我最近才了解 MATCH AGAINST,所以我不确定在我的案例中使用它的“正确”方法。就像我说的,我有一个表,其中有一个名为 description
的列,使用上面的示例单词 assists
,它在表中出现多次,我会使用这个查询:
SELECT * FROM challenges WHERE MATCH(description) AGAINST('assists')
我刚刚执行了它,它返回了 10 行。如果我将其更改为 assist
,我什么也得不到。
I'd like to add a search to my site. I have a database of challenges from a video game. Each challenge has a title and description, I'd like to be able to search at least the description, but both if possible. Now, I've set the table up so that I can use MATCH() AGAINST(), but I'm having a problem with words that can be either singular or plural.
For example, the word "assists" appears in multiple challenges, but if the user types "assist", he won't get anything. Is there any way that I can add that functionalty? I've tried everything I can think of, but nothing has worked so far.
Update: I only just recently learned about MATCH AGAINST, so I'm not sure the "right" way to use it in my case. Like I said, I've got a table with a column called description
, using the example word from above, assists
, which appears multiple times in the table, I would use this query:
SELECT * FROM challenges WHERE MATCH(description) AGAINST('assists')
I just executed that and it returned 10 rows. If I change it to assist
, I get nothing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许您可以使用 MySQL 中的 SOUNDEX() 函数。
我认为这也可能适用于你,他会用复数
Maybe you can use the SOUNDEX() function from MySQL.
I think this also may be applicable for you and that he will take with plurals
我可能错过了你想要做的事情的要点,但为什么不直接做这样的 LIKE 匹配:
它将匹配任何包含“assist”和“assists”的内容。当然它也会匹配“助理”和“协助”,这可能不是你想要的......
I might be missing the point of what you're trying to do, but why not just do a LIKE match like this:
That will match anything that contains "assist" as well as "assists". Of course it will also match "assistant" and "assistance", which may not be what you want...