File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes How to implement did you mean this Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to implement did you mean this" Watch "How to implement did you mean this" New topic
Author

How to implement did you mean this

fu bace
Greenhorn

Joined: Oct 16, 2009
Posts: 24
I am not sure if i wrote this on the right category.

My question is this. For example i have a product table and there is a column name product_title.

When user searches a record in this table, if he searchs for example "nokai n 97" or "nokai n97" i should say did you mean this "nokia n97".

I searched for string matchin algorithms and i found levensthein. I used it but it is so slow as expected.

What are your opinions about this subject. What should i do, how should i do?
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3704
    
    5

There's no simple way to implement what you are talking about. Many databases do implement Soundex functionality which converts the input to phonic sounds, in the hopes of finding things that sound the same, but it is far from perfect. The best you can do on a regular database would be to try 4-5 variations on the search, for example removing spaces, but that would branch the number of queries significantly. As far as I know, you need advance search tools, often 3rd party or home grown, to accomplish what you are talking about.


My Blog: Down Home Country Coding with Scott Selikoff
fu bace
Greenhorn

Joined: Oct 16, 2009
Posts: 24
Hi i heard soundex too. But the language is a important point at that point.

You said 3rd party tool. I think I should use levensthein with Lucene, Solr or something else that are related to these which makes the select queries much faster by the help of indexes.
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2495
    
    8

Try googling for "sql fuzzy search". Not too much to be found, but there are solutions for several databases. Maybe there is a match for your database.


OCUP UML fundamental and ITIL foundation
youtube channel
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to implement did you mean this