Connecting Tech Pros Worldwide Forums | Help | Site Map

mysql search close result

Bob Bedford
Guest
 
Posts: n/a
#1: Jul 21 '05
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ß
Guest
 
Posts: n/a
#2: Jul 21 '05

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]
Steve
Guest
 
Posts: n/a
#3: Jul 21 '05

re: mysql search close result



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

http://dev.mysql.com/doc/mysql/en/fulltext-search.html

---
Steve

Closed Thread