Upgrading the Search Function

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.


3 thoughts on “Upgrading the Search Function

  1. I’ve done searches on your blog before and have not had much success. But that was on the old site, and maybe that was a better search engine. Which means I ask hard or dumb search requests.
    I am a big fan of google, because it gives me what I want. Which is interesting, because I wonder if other search engines are better, but google has caused me to adapt to their style, and old habits die hard. I’ve occassionally tried Ask or Yahoo, and the answers are amazingly bad. And with what anecdotedly seems like a huge advertising factor, i.e. I google muddled ramblings and the top answer is “Amazon, find books about muddled here!”
    Nonetheless, I am a hypocritical handwringer over google. It really bugs me that their company motto is do no evil and yet they self censor in China. Alas, I still use them.

  2. And see…google has me so captured that I used the term “googled” above when referring to searches on Ask or Yahoo. Since I can’t edit my comment, I have to “edit” here that I mean “searched” in the above comment.

  3. This past weekend, the student information system at the community college where I work was completely shut down in order to make major improvements to the system.

    One of the “improvements” was to replace Google with bing. It is NOT an improvement. I wanted to put link to a website on the course homepage for one of the classes I’m teaching. I knew what website I wanted; I just couldn’t remember the URL. I put some keywords into the search blank that I was sure would bring up the site I wanted.

    No such luck. The sites that bing brought up had, for the most part, no relationship whatsoever to the search I thought I was making. Dogpile would have done a better job of pulling up relevant sites.

    Oh, yeah, bing is sure pretty. As long as one has a high-speed connection, maybe the cool graphics are the reason to use that search engine. But at home, on dial-up? You gotta be kidding. I have no idea what factors went into the decision the college made to switch from Google to bing, but it was the wrong decision.

Leave a Reply

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