Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Word Boundary

Author  Topic 

stakadush
Starting Member

2 Posts

Posted - 2002-01-24 : 20:12:52
Hey
Is there a way to make the search more accurate?
Let's say a user want to search for 'big'. The procedure would return things like 'bigamy' and 'bigger'. Is there some kind of a word boundary switch that can be used (like \b with regular expressions), to prevent this?
Thanks :)

Article Link: [url]http://www.sqlteam.com/item.asp?ItemID=5857[/url]



Edited by - stakadush on 01/24/2002 20:21:06


Rob Volk-

Moved this to Developer forum.

I think this modification should do it (see bold):


Select ArticleID, ArticleTitle, ArticleDescription, count(AA_ID) hits
FROM SEQUENCE
INNER JOIN Articles ON Articles.ArticleBody like '%' +
Substring(' ' + @keywords + ' ',seq,
CharIndex(' ' , ' ' + @keywords + ' ' , seq) - seq)
+ '[ !.,;]%'

WHERE
seq <= len(' ' + @keywords + ' ') and
Substring(' ' + @keywords + ' ', seq - 1, 1) = ' ' and
CharIndex(' ' , ' ' + @keywords + ' ' , seq) - seq > 0

Group by ArticleID, ArticleTitle, ArticleDescription

ORDER BY Hits DESC


That'll change the LIKE argument to look for a word boundary character (space, comma, etc.) after the search word; you can modify it to meet your needs. However, you will lose any matches that occur at the very end of the search item, unless you concatenate a word boundary character to the end of the search item.

Edited by - robvolk on 01/25/2002 13:57:23
   

- Advertisement -