mysql search close result

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bob Bedford

    mysql search close result

    I don't have mysql Newsgroup access so let me try here.

    I've to find in a table the "closer" result given some text.

    Here is a little example:

    given the text "Batman socks" I've to find the best matching result in
    choices like:
    -"mickey socks"
    -"robin socks"
    -"batman black socks" ->this should be found
    -"batman wallet"
    -"batman"

    or given the text "leather shoes" I've to find the best matching result in
    choices like:
    -"socks"
    -"shoes" ->this should be found
    -"pants"
    -"shirts"
    -"leather wallet"

    My problem is to get the best choice where I've too many informations in the
    given text.
    I mean using - like '%Batman%' and like '%socks%'- will work for the first
    case, but not the second.

    Any idea ?

    Bob


  • Joachim Weiß

    #2
    Re: mysql search close result

    Bob Bedford schrieb:[color=blue]
    > given the text "Batman socks" I've to find the best matching result in
    > choices like:
    > -"mickey socks"
    > -"robin socks"
    > -"batman black socks" ->this should be found
    > -"batman wallet"
    > -"batman"[/color]
    ....

    The trick is that you use an algortihm that seeks the nearest difference
    between two texts.[color=blue]
    > Any idea ?
    >[/color]
    Use the 'levenshtein' function. However the Problem might be that you
    have to go through your database sequentially.

    I've programmed somthing for single words (to suggest oranges when
    orangse are typed). In that case the soundex function did a lot of work
    to get a smaller subset of the database.

    I'm afraid that if the database is very large, the world will be saved
    by a barefooted batman. Tasty!


    Jo
    [color=blue]
    > Bob
    >[/color]

    Comment

    • Steve

      #3
      Re: mysql search close result


      Bob Bedford wrote:[color=blue]
      > I've to find in a table the "closer" result given some text.[/color]



      ---
      Steve

      Comment

      Working...