MYSQL Fulltext search and LIKE

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-21 09:12:03

问题


I am working with MySQL full text search but find it lacking in situations where your string is part of a word within a field. If my field is "New York Times" and I search for "Time" I get no results. The hackish way to solve this is to set up two queries, one that does a full text search and the other that does:

SELECT * FROM ___ WHERE 'string' LIKE %searchterm% 

Is there any way that I can set up my full text search to solve this issue so I don't have to run the extra query?


回答1:


I've basically given up on MySql's full text search in favor of Sphinx -- a dedicated full-text search engine which implements MySql's network protocol so you can "interpose" it between your clients and a MySql server, losing nothing and gaining rich, serious full-text capabilities. Maybe it's not suitable for your needs (which you don't fully express), but I think it's at least work checking out!




回答2:


You can use wild cards in your full text search. More info here

SELECT * FROM _____ WHERE MATCH (title) AGAINST ('time*' IN BOOLEAN MODE);


来源:https://stackoverflow.com/questions/1437066/mysql-fulltext-search-and-like

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!