Groups | Blog | Home
all groups > sql server full text search > september 2003 >

sql server full text search : Word order dependent search


fts
9/8/2003 6:02:58 AM
We need to have a functionality whereby we can have
Word order dependent search - All words entered appear in
the term in the order entered.

Can we accomplish this using FTS?

Hilary Cotter
9/8/2003 6:34:07 AM
wrap your search in double quotes and use a contains or
containstable search
[quoted text, click to view]
fts
9/8/2003 8:03:22 AM
Thanks for your reply.... However, if I put the "" then
am I not searching for the exact string match? I guess I
should have explained a little better...

What I am trying to accomplish is...If someone passes in
the combination of words...

WORD1 WORD4 WORD2

When searching using FTS...I only want to select records
that have the pattern WORD1 % WORD4 % WORD2
These words dont necessarily have to follow one another
consecutively but when selecting the resultset should be
occurring in the same order within the search result...

AND

NOT select any records that may have the same words
occuring in a different order For eg - WORD2 % WORD1 %
WORD4

Is there a neat way of doing this with FTS?

Thanks again...

[quoted text, click to view]
John Kane
9/8/2003 8:24:47 AM
fts,
To the best of my knowledge (and I've worked with SQL FTS since it was first
incorporated in SQL 7.0 beta3 in 1998), there is no direct way to do this
with SQL FTS. The closest you can come is using the NEAR (or ~ symbol) with
CONTAINS or CONTAINSTABLE, for example:

select * from containstable(Employees,
Notes,'"1970~psychology~University~Nancy"')

will find "1970 near psychology near University near Nancy" but not
necessarily in that order.

I suspect that you're looking for a Google-like functionality, for example
using this string with in double quotes - "sql * best * database" - on
Google this can find "SQL The best designed database". Correct? Assuming so,
you would have to develop your own custom stored proc (or UDF?) to capture
the individual word search results as well as position of each word in the
row into a temp table and then re-order the results based upon search words
and their positions... et.al.

Regards,
John




[quoted text, click to view]

fts
9/8/2003 8:37:19 AM
Yep...That's what I am trying to do...and was hoping to
find a neat way of doing it. I guess not!

Thanks for your help!

[quoted text, click to view]
AddThis Social Bookmark Button