What you are trying to do is full-text search with rankings.
MySQL has MATCH , but it only works on the columns on which the index is built, for example, FULLTEXT (title,body) . Previously used on MyISAM, now available in Innodb 5.6+ .
SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('ΠΌΠΎΡΠΊΠ²Π° Π°Π²ΡΠΎΠΌΠΎΠ±ΠΈΠ»Ρ ΠΊΡΠ΅Π΄ΠΈΡ');
Read more
But there will be problems with the morphology of words: Π² ΠΌΠΎΡΠΊΠ²Π΅ they will not find it anymore. Here they propose to process the entire text (stemming), and already search for this text. So-so solution.
You are probably not satisfied with the quality of the search. The fact is that databases are not sharpened by full-text search and ranking, they evolve in other directions.
Correct solution
Therefore, you should use special solutions: Sphinx, its fork Mandragora, or ElasticSearch.
For Sphinx there is a SQL-like language , the connection also goes through the MySQL interface.
SELECT * FROM index WHERE MATCH('ΠΌΠΎΡΠΊΠ²Π° Π°Π²ΡΠΎΠΌΠΎΠ±ΠΈΠ»Ρ ΠΊΡΠ΅Π΄ΠΈΡ');
You like? Use.
More Sphinx chips:
- rt-index allows you to update the Sphinx index on the fly. Have you updated the news in MySQL? The second command update rt-index
- snippets - "podstvetka" keywords in the found text
- faceted search