The other day I wondered how many times I’d used the phrase “You don’t have to thank me” in this blog. No problem, I thought, I’d just pop the phrase into the search feature over on the sidebar and let it tell me.
The only problem was, it didn’t give a very good answer. It also included partial matches, which would have been all right if it had either a) ranked the results, or b) shown a little excerpt of the resulting matches with the searched-upon words emphasized. The built-in WordPress search function does neither. Off I went to find alternatives.
One option was to hook up Google to do the search. That’s a pretty good option from a functional standpoint; nobody is as good at ranking results and showing you a bit to help you with your decision. The downside is that it’s pretty ugly. My (very) brief search made it appear that I wouldn’t be able to do much with the results. My search for Google-based solutions was brief because I found another WordPress plugin called “Better Search” which did in fact return ranked answers. Hooray!
Only, not so fast, Sparky. The plugin is still young, and doesn’t provide much in the way of customizing the look of the results, either. The good news was that the source code is right there and I thought it wouldn’t be too tough to rearrange things a bit to make it much easier to customize. The plugin author had already done the mysterious, magical steps to allow a template file to work, all that was left was giving the template the power. So I did that, and sharpened up some PHP skills while I was at it. Now if you do a search, you will see that the results include a relevance ranking. The result page is still pretty ugly, because I haven’t finished tweaking my new template for my site. (I tried to start with a general one that would be useful to others.)
Then, I typed “You don’t have to thank me” into the search box and got… No matches found. What? I know I’ve used that phrase before. I tried removing the word with the apostrophe, in case that had something to do with it. Nope. Eventually I got down to the word “thank”. No matches.
Here’s the thing: MySQL, the database I use, has built this fancy full-text matching thing (which I learned an awful lot about yesterday), but they’ve optimized it for huge sites. There is a list of common words they throw out to reduce the number of matches. Six of those words are “you”, “don’t”, “have”, “to”, “thank”, and “me”. Wow. To make things worse, I can’t change the list. Only the big boys who have their own servers can control the list. Those are the ones least likely to want to change the list, but there you go.
There were some other annoying “features” of the MySQL Full-Text search (exact phrase matching doesn’t work like you’d think, for instance), but some of those I suspect are the result of my provider using an older version of the database.
Now, I can put up with the limits of MySQL (this morning i was coding in my head the algorithm for showing an excerpt with emphasis), or shift focus and let the Goog or it’s new arch-rival bing do the heavy lifting – and the formatting. Why can’t this stuff just be easy?
Edited to Add: Well, that blog episode went obsolete in a hurry. I’m currently using a Google sidebar thingie that is visually acceptable (and adaptable). Play around with it!
There is a feature of the Better Search plugin I was using that I will miss – it kept track of recent searches and produced one-click links in a cloud that showed popularity. I guess it’s not a major loss, since not that many people search here, but I liked it.