PHP / MySQL relevance in searching

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gregerly
    Recognized Expert New Member
    • Sep 2006
    • 192

    PHP / MySQL relevance in searching

    Hello,

    I appologize as I've posted this in the PHP forum as well, but I think it is relevant here as well.

    I've got a problem with a website search function. PHP for the front end, MySQL for the backend. The search function searches a field of keywords. The problem I'm having is that when someone searches for "Italian Food" it's bring back results for other resteraunts that are not italian, but do have the word Food in their keywords. Is there a way of adding relevance to a search, in a way that would make sense for the above senario?

    Thanks in advance,

    Greg
  • mwasif
    Recognized Expert Contributor
    • Jul 2006
    • 802

    #2
    Use MySQL's FULLTEXT search. You can also use FULLTEXT in BOOLEAN MODE.

    Comment

    • Atli
      Recognized Expert Expert
      • Nov 2006
      • 5062

      #3
      If you can't / won't use a fulltext search, you could always split the search string into words, and search for results for each word, and then rank each result based on how many of the words match it.

      For example, if you search for 'Italian food' and restaurant A has the keyword 'FOOD', and restaurant B has both the word 'ITALIAN' and 'FOOD' then you could rank A = 50% and B = 100%, and return the results based on the ranking.

      Comment

      Working...