Better searches in s9y

mysql limits you by default to search for strings no smaller than 3 characters, so, if i wanted to look for “dd” in
s9y i had no luck.
F*n grep is better than mysql with that > 3 chars limit.
s9y also uses MATCH and AGAINST which makes searches a bit dumb.
To overcome this i added the parameter “–ft_min_word_len=1” to mysql startup, so we can search strings
shorter than 3 chars.
/usr/bin/mysqld_safe –ft_min_word_len=1 –datadir=/var/lib/mysql –pid-file=/var/run/mysql/mysql. pid $SKIP &
To make ft_min_word_len take effect you have to reindex the tables you wish to search with less than 3
chars. To do it:
mysql> repair table serendipity_entries quick;
+———————————+——–+———-+———-+
| Table | Op | Msg_type | Msg_text |
+———————————+——–+———-+———-+
| serendipity.serendipity_entries | repair | status | OK |
+———————————+——–+———-+———-+
1 row in set (0.20 sec)
mysql> repair table serendipity_authors quick;
+———————————+——–+———-+———-+
| Table | Op | Msg_type | Msg_text |
+———————————+——–+———-+———-+
| serendipity.serendipity_authors | repair | status | OK |
+———————————+——–+———-+———-+
1 row in set (0.00 sec)
mysql> repair table serendipity_entrycat quick;
+———————————-+——–+———-+———-+
| Table | Op | Msg_type | Msg_text |
+———————————-+——–+———-+———-+
| serendipity.serendipity_entrycat | repair | status | OK |
+———————————-+——–+———-+———-+
around line 773 of s9y include/functions_entries.inc.php we changed MATCH and AGAINST for LIKE
//– rdircio, better searches here
// $cond[‘find_part’] = “MATCH(title,body,extended) AGAINST(‘$term’ IN BOOLEAN MODE)”;
50/433
$cond[‘find_part’] = “(title LIKE ‘%$term%’ OR body LIKE ‘%$term%’ OR extended LIKE
‘%$term%’)”;
} else {
// $cond[‘find_part’] = “MATCH(title,body,extended) AGAINST(‘$term’) “;
$cond[‘find_part’] = “(title LIKE ‘%$term%’ OR body LIKE ‘%$term%’ OR extended LIKE
‘%$term%’)”;
}
Now, you can enter text in the quicksearch like ” tar c ” at this blog and it will find entries like ” tar cvf” and not
entries like “start”
51/433

Leave a Reply

Your email address will not be published. Required fields are marked *