Answer the question
In order to leave comments, you need to log in
MySQL search via match() against()?
Hello!
I have a search that searches using match() against(). But the problem is that it does not give accurate results. For example, if you do a search for “cat”, it displays not cats on the front page, but what contains “Category”.
The question is simple - How do I make LIKE '% cat %' OR tags LIKE '% cat' OR tags LIKE 'cat %' in match() against()
More details:
Tags are stored as "animal cat happy" or "" "inventory categories"
Here is the sql to search compact disc
SELECT *, MATCH (tags) AGAINST('>>"compact disc" >(+compact* +disc* ) <(compact* disc* )' IN BOOLEAN MODE) as rel FROM icons <br/>
WHERE MATCH (tags) AGAINST('>>"compact disc" >(+compact* +disc* ) <(compact* disc* )' IN BOOLEAN MODE) <br/>
ORDER BY rel DESC
(SELECT * FROM icons WHERE tags LIKE '% cat %' OR tags LIKE '% cat' OR tags LIKE 'cat %')<br/>
UNION<br/>
(SELECT * FROM icons WHERE tags LIKE '%cat%')<br/>
Answer the question
In order to leave comments, you need to log in
LIKE gives a huge load on the DBMS.
It all depends on which table engine you are using. For full-text search with morphology, sphinx is the best choice.
If to do through match it is best of all MyISAM.
but in general www.mysql.ru/docs/man/Fulltext_Search.html
SELECT word FROM table WHERE
MATCH (word) AGAINST ('cat*' IN BOOLEAN MODE)
If the string with tags in the database starts with a space and ends with a space, then three conditions will not be necessary: )
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question