Fuldtekstmatch
Du kunne se på at implementere noget, der ligner MATCH
eksempel her
:
mysql> SELECT id, body, MATCH (title,body) AGAINST
-> ('Security implications of running MySQL as root') AS score
-> FROM articles WHERE MATCH (title,body) AGAINST
-> ('Security implications of running MySQL as root');
+----+-------------------------------------+-----------------+
| id | body | score |
+----+-------------------------------------+-----------------+
| 4 | 1. Never run mysqld as root. 2. ... | 1.5219271183014 |
| 6 | When configured properly, MySQL ... | 1.3114095926285 |
+----+-------------------------------------+-----------------+
2 rows in set (0.00 sec)
Så for dit eksempel, måske:
SELECT id, MATCH (content) AGAINST ('your string') AS score
FROM messages
WHERE MATCH (content) AGAINST ('your string')
AND score > 1;
Bemærk, at for at bruge disse funktioner dit content
kolonne skal være en FULLTEXT
indeks.
Hvad er score
i dette eksempel?
Det er en relevance value
. Det beregnes gennem processen beskrevet nedenfor:
Fra dokumentationen side.