Home All Groups Group Topic Archive Search About
Author
13 Jan 2006 7:46 PM
Fabio Cavassini
Having a list of words in a table...haw can I make with SQL a "did you
mean" search?

for example..

Having a table with these data:

hello
hallo
hi
lup
hai

If I look for "hollo" it should return "hello", "hallo"

I know this could be a very complex algorithm, but I'm looking for it's
simplest form that could be implemented with Transact SQL

Best Regards
Fabio Cavassini
http://www.pldsa.com

Author
13 Jan 2006 8:22 PM
Hilary Cotter
Have a look at the thesaurus feature in SQL FTS. This is supported in SQL
2005, and unsupported but implemented for FreeText search in SQL 2000.

--
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html

Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com

Show quote
"Fabio Cavassini" <cavassi***@gmail.com> wrote in message
news:1137181586.850037.17240@g43g2000cwa.googlegroups.com...
> Having a list of words in a table...haw can I make with SQL a "did you
> mean" search?
>
> for example..
>
> Having a table with these data:
>
> hello
> hallo
> hi
> lup
> hai
>
> If I look for "hollo" it should return "hello", "hallo"
>
> I know this could be a very complex algorithm, but I'm looking for it's
> simplest form that could be implemented with Transact SQL
>
> Best Regards
> Fabio Cavassini
> http://www.pldsa.com
>
Author
13 Jan 2006 8:41 PM
SQL
This will work for you
it will be expensive (table scan etc) but it's the simplest form
you could put it in a UDF
add i, u and y for the complete set

create table testString (value varchar(55))
insert into testString
select 'hello' union all
select 'hallo' union all
select 'hi' union all
select 'lup' union all
select 'hai'

declare @Value varchar(55)
select @value = 'hollo'

select * from testString
where  replace(replace(replace(value,'e',''),'a',''),'o','') =
replace(replace(replace(@value,'e',''),'a',''),'o','')


http://sqlservercode.blogspot.com/
Author
13 Jan 2006 8:33 PM
JT
Are saying that you want to select all rows where key values resemble a
given parameter?

There is the LIKE operator for performing truncated, wildcard, or
substitution type comparisons. For example:

select * from words where word like 'hel%'
select * from words where work like 'h_ll_'

There is also the SoundEx() function which accepts a character string and
returns a condensed code based on the string's phoenic spelling. For
example:

select * from words where word = SoundEx('hello')

print soundex('hello')
H400
print soundex('hallo')
H400
print soundex('half')
H410

This is also useful when searching on first or last names.

The most accurate solution would be to have a referece table which maps each
word to 0 - many equivalent words.

select word from Thesaurus where synonym = 'hello'

Show quote
"Fabio Cavassini" <cavassi***@gmail.com> wrote in message
news:1137181586.850037.17240@g43g2000cwa.googlegroups.com...
> Having a list of words in a table...haw can I make with SQL a "did you
> mean" search?
>
> for example..
>
> Having a table with these data:
>
> hello
> hallo
> hi
> lup
> hai
>
> If I look for "hollo" it should return "hello", "hallo"
>
> I know this could be a very complex algorithm, but I'm looking for it's
> simplest form that could be implemented with Transact SQL
>
> Best Regards
> Fabio Cavassini
> http://www.pldsa.com
>
Author
13 Jan 2006 8:38 PM
David Gugick
Fabio Cavassini wrote:
Show quote
> Having a list of words in a table...haw can I make with SQL a "did you
> mean" search?
>
> for example..
>
> Having a table with these data:
>
> hello
> hallo
> hi
> lup
> hai
>
> If I look for "hollo" it should return "hello", "hallo"
>
> I know this could be a very complex algorithm, but I'm looking for
> it's simplest form that could be implemented with Transact SQL
>
> Best Regards
> Fabio Cavassini
> http://www.pldsa.com

Have a look at the soundex function, and consider storing the soudnex values
in the table to avoid table scan operations each time. Best to do this from
the stored procedure that does the inserting:

create table SoundexTest (Col1 varchar(30), Col1Soundex char(30))

create index Col1SoundexIDX on SoundexTest (Col1Soundex)

Insert into SoundexTest Values ('Hello', SOUNDEX('Hello'))
Insert into SoundexTest Values ('Hallo', SOUNDEX('Hallo'))
Insert into SoundexTest Values ('Hey', SOUNDEX('Hey'))

Select * from SoundexTest where Col1Soundex = SOUNDEX('Hallo')

drop table SoundexTest

--
David Gugick
Quest Software
Author
13 Jan 2006 8:39 PM
David Gugick
Fabio Cavassini wrote:
Show quote
> Having a list of words in a table...haw can I make with SQL a "did you
> mean" search?
>
> for example..
>
> Having a table with these data:
>
> hello
> hallo
> hi
> lup
> hai
>
> If I look for "hollo" it should return "hello", "hallo"
>
> I know this could be a very complex algorithm, but I'm looking for
> it's simplest form that could be implemented with Transact SQL
>
> Best Regards
> Fabio Cavassini
> http://www.pldsa.com

As well as this:
http://techrepublic.com.com/5102-9592-5716625.html

--
David Gugick
Quest Software
Author
13 Jan 2006 9:11 PM
Robert Fuchs
and where are Listing A and Listing B ?

regards, Robert
Author
20 Jan 2006 4:53 AM
David Gugick
Robert Fuchs wrote:
>> As well as this:
>> http://techrepublic.com.com/5102-9592-5716625.html
>
> and where are Listing A and Listing B ?
>
> regards, Robert

http://techrepublic.com.com/5100-9592_11-5716625.html?tag=search

--
David Gugick
Quest Software
www.quest.com
Author
20 Jan 2006 5:56 AM
--CELKO--
>>  know this could be a very complex algorithm  <<

OH YES!!  Do not do this kind of search in SQL; use a textbase tool
which has the complex algorithms tuned for a particlar natural
language, like English.
Author
20 Jan 2006 11:58 AM
Tony Rogerson
What like the Full-Text search facilities that are already built into SQL
Server and allow you to join returned documents from your text search
against your schema - extremely powerful i'd say.

Really, have a look at the complete feature list that is offered in SQL
Server, its not just a relational data storage and retrieval engine.

--
Tony Rogerson
SQL Server MVP
http://sqlserverfaq.com - free video tutorials


Show quote
"--CELKO--" <jcelko***@earthlink.net> wrote in message
news:1137736598.084973.118370@z14g2000cwz.googlegroups.com...
>>>  know this could be a very complex algorithm  <<
>
> OH YES!!  Do not do this kind of search in SQL; use a textbase tool
> which has the complex algorithms tuned for a particlar natural
> language, like English.
>
Author
24 Jan 2006 1:34 PM
Fabio Cavassini
Lot of interesting stuff...I'll need some time to review it...and then
I'll tell you the results I get...

Best Regards
Fabio Cavassini

AddThis Social Bookmark Button