New Search Functionality

I’ve been having trouble finding a good location to fit the Google search box on The recent changes to the site layout that I’ve made seem to be working well, but search volumes were down, which I have taken to be a bad sign.

In order to get more flexibility in terms of the placement of the search box, I’ve replaced the Google search box with a new search box, backended with some new search functionality I’ve written, based on MySQL Fulltext Search. This has advantages and disadvantages compared to using Google:

Disadvantages of the new solution:

  • It doesn’t current show snippets of the matching text in the results
  • There are no Google adverts, which were a small revenue stream for the site
  • Parts of the site other than the reviews and comments are not searchable
  • It can’t spot spelling errors
  • There is no rich syntax like Google offers
  • In order to increase performance, the search is limited to a max of 200 results. The search doesn’t compute the maximum number of results if there are more than 200. Interestingly, Google themselves only show about 1000 results, even when they find a lot more. For queries with thousands of results, Google state “about” how many they have found. So I doubt they are calculating that part of the result in real time

Advantages of the new solution:

  • It’s fast. As long a query limit is in place stop it trying to return 20,000 results, MySQL Fulltext Search seems to fly. And there’s no need to do a DNS lookup for Google
  • It’s complete and up-to-date – no need to wait for any spider to visit the site
  • Comments that are found are linked to directly using an HTML anchor
  • The new search looks specifically for model and manufacturer searches, and displays special results at the top of the page for these common cases
  • More control over the look and feel of the search box and results
  • No adverts

Just in case anyone misses the Google Search, I’ve placed a Google box at the bottom of the search results page. So you still have the choice to use Google if my new search is not delivering good results.

This change has allowed me to move the search box across to the left of the page. Hopefully it will be more obvious to visitors there.

While making this change, a few other minor issues were addressed. In particular, some margins have been changed from being in pixels to em units. This makes the site look nicer with large fonts.

As usual, any feedback is welcome.

6 thoughts on “New Search Functionality

  1. Gary

    For search spelling suggestions I recommend pspell.

    And for highlighting searches, how about…

    $search = ‘test’;
    $search_result = ‘my test str’;
    echo $search_result.”\n”;
    $search_result = preg_replace(‘/(‘.$search.’)/’,’\1‘,$search_result);
    echo $search_result.”\n”;

  2. Gary

    Apologies above, it escaped the example bold tags 🙂

    $search = 'test';
    $search_result = 'my test str';
    echo $search_result."\n";
    $search_result = preg_replace('/('.$search.')/','<b>\1</b>',$search_result);
    echo $search_result."\n";

  3. Steven Post author

    Thanks Gary,

    Might have to consider using pspell. Hopefully there’s a way to install it on Redhat Enterprise Linux 4 without recompiling PHP.

    The issue with the highlighting of search words is that the destination pages are supposed to be static HTML (they’re actually PHP with a bit of mod_rewrite magic). Would have to point the results at a plain PHP page to allow the passing of the parameters needed for highlighting. Will have to give the issue some thought.

  4. Gary

    What parameters would you need to pass?

    You’re building the page of results and you have the search string.

    Just a quick preg before writing the page.

  5. Steven Post author

    You’re right – it was late at night and I was thinking of highlighting the keywords in the destination page, ala Google Cache. You’re right about it being pretty easy to do in the search results page itself.

  6. Pingback: Distant Parts » Blog Archive » Search the Airline reviews

Leave a Reply