[module] Short Search Fix - make 2-3 character searches work

shadlaws

Joined: 2012-03-14
Posts: 183
Posted: Tue, 2012-04-03 13:40

Hey everyone,

NEW: Version 2 is out! Attached below.

Short, 2-3 character searches typically don't work with standard MySQL implementations, especially with shared hosting. This module fixes that.

The core of the search function uses MySQL do perform the search query. However, MySQL system variables limit the minimum word length (ft_min_word_len) and exclude some words (ft_stopword_file). These parameters are often read-only for shared hosting accounts (e.g. GoDaddy). This seriously sucks, especially if you have a bunch of 2-3 letter tags.

So, this module pads all search terms and search queries with a prefix to make them longer than 2-3 letters. To the user, the search queries and results are the same, but to MySQL, they've all gotten longer. In this way, we circumvent the limitations.

A zip of the module is attached. Also, I've written documentation, which is available in the usual place at [http://codex.gallery2.org/Gallery3:Modules:short_search_fix].

Enjoy!

Take care,
Shad

AttachmentSize
short_search_fix_2.zip6.41 KB
 
shadlaws

Joined: 2012-03-14
Posts: 183
Posted: Thu, 2012-05-03 11:55

Hey everyone,

I've tested with Gallery v3.0.3 and it works great - no upgrade needed.

The only *veeeery* minor change is the copyright date. Since the MY_search.php file is largely taken from the search.php in the main distribution, 2011 changed to 2012. I've updated the zip file attached here, but no real update is needed.

Thanks,
Shad

 
shadlaws

Joined: 2012-03-14
Posts: 183
Posted: Mon, 2012-10-08 16:12

Hey everyone,

Version 2 is out! I made the module compatible with all boolean SQL special characters (ref http://codex.gallery2.org/Gallery3:Modules:search and http://dev.mysql.com/doc/refman/4.1/en/fulltext-boolean.html).

This arose out of a discussion here: http://gallery.menalto.com/node/108830

Take care,
Shad