开发者

MySQL Fulltext (Not) Searching

开发者 https://www.devze.com 2023-03-26 03:38 出处:网络
I have a table where there are video data, like \"title\", \"description\" etc. I\'m trying to write a search engine with MySQL fulltext indexing. The SQL query works with some words but not every wor

I have a table where there are video data, like "title", "description" etc. I'm trying to write a search engine with MySQL fulltext indexing. The SQL query works with some words but not every word. Here is my SQL query;

SELECT *
FROM videos
WHERE MATCH (title, description) AGAINST ('XXXXXXXXXX' IN NATURAL LANGUAGE MODE)

where I replace "XXXXXXXX" with the query terms. It works with "otomotiv" but not with "otomoti". Doesn't it have to find "otomoti" if it finds "otomotiv", as "otomoti" is part of the whole word "otomotiv"?

I tried changing the search mode to "IN NATURAL LANGUAGE MODE" or "WITH QUERY EXPANSION" b开发者_运维问答ut still no luck.

Is it normal that MySQL can't find a part of the whole word?


You need to perform boolean full text search as it supports wildcard operator.
http://dev.mysql.com/doc/refman/5.5/en/fulltext-boolean.html

SELECT *
FROM videos
WHERE MATCH (title, description) AGAINST ('otomoti*' IN BOOLEAN MODE)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号