Making the Search Function more useful

Some time back I attempted to make the osCommerce native search function a little more useful by coming up with code to allow the search result to offer alternatives if the product being searched for cannot be found.

My idea was in case of mis-spellings. I gave up as I could not get much of anything to work well, without some major coding. Fast forward about 3 years to now…and a forum post gave me an idea to try…

How it is now

Go to http://demo.oscommerce.com/advanced_search.php and search for the DVD movie called “Beloved”. But deliberarely mis-spell as so; belovd

What is the result?

With my changes, the result would be like this

As you can see, the “Beloved” DVD is returned in a “recommendations” box, even though the search was mis-spelled. This allows the user to easier find what they are looking for.

Another example is the mis-spelling “matrex” – is the person looking for “The Matrix” or “Matrox G200”? Try it at the osCommerce Demo Search Page – no result!

And now watch the video showing the “belovd” search and the “matrEx” search;

I’m still working on the codebase, so if anyone has any input let me know. Should this “fuzzy” search also give results when an exact match IS found? Eg, if a search is made for Matrix, should the Matrox products also show in the search results?

Updated Video, based on Isa’s idea for similar searching

12 Replies to “Making the Search Function more useful”

  1. Hi Gary

    Nice idea this fuzzy search 🙂
    Personally I think that it should give results even when an exact match is found, because who knows what the person really wanted to type? Perhaps they typed “Matrix” but were really meaning to type “Matrox”.
    So when typing “Matrix” there could be a box with the exact match and underneath another box with similar results.

  2. That is pretty cool!
    do you have to attach misspelled versions of search criteria into a database, or does this figure it out automatically?

    I totally agree with Isa, even though i didn’t before i read the comment 🙂 – good point with Matrix/Matrox..

  3. Isa, I think you are right – having a “similar” box underneath the “exact” results would work well.

    Steph, no manual input for mis-spellings at all 🙂

  4. OK, a bit of jiggery with the code and I have a working search module that returns similar results even if an exact match is found. As there is no manual input, and all is done by logic, it’s not perfect. But it is certainly more usable than the standard search. See the updated video.

  5. I like it a lot! :):)
    With this method you always propose something to the visitor, rather than giving him a nasty phrase like “There is no product that matches the search criteria”

  6. The other thing I thought was good on a website today, was if a result is not returned on a search, a form appears with the search term already populated so all you have to do is add your contact details and send the product request into the store owner.

  7. Hi Paul – that’s certainly possible. Can you email me that link you found that shows it in action?

Leave a Reply

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