Tuesday, November 02, 2004

today
learn about mysql search function MATCH() and AGAINST
klu
mysql> SELECT * FROM articles
-> WHERE MATCH (title,body) AGAINST ('database');

dekat statement tuh akan carik
dlm field title and body yg ader word database..

mysql> SELECT id, MATCH (title,body) AGAINST ('Tutorial')
-> FROM articles;
+----+-----------------------------------------+
| id | MATCH (title,body) AGAINST ('Tutorial') |
+----+-----------------------------------------+
| 1 | 0.65545833110809 |
| 2 | 0 |
| 3 | 0.66266459226608 |
| 4 | 0 |
| 5 | 0 |
| 6 | 0 |
+----+-----------------------------------------+

wah kat atas nie lagie menarik..
buleh kasi value how many percent match dengan word yg di cari


last sekalik combination

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)


MySQL uses a very simple parser to split text into words. A ``word'' is any sequence of characters consisting of letters, digits, `'', or `_'. Some words are ignored in full-text searches:

- Any word that is too short is ignored. The default minimum length of words that will be found by full-text searches is four characters.
- Words in the stopword list are ignored. A stopword is a word such as ``the'' or ``some'' that is so common that it is considered to have zero semantic value. There is a built-in stopword list.

::ku yg terhegeh2 ;_)::

1 comment:

Shara said...

bestnye.. banyak benda baru ko belajar.. aku kat sini cam lesser improvement... :(