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
 Transact-SQL (2000)
 Help with ordering based on pos/neg keywords

Author  Topic 

ben21
Starting Member

5 Posts

Posted - 2006-12-17 : 09:10:28
Hi there,
I’ve been tasked with creating a basic search function for a very low volume advert list. My T-SQL isn’t too hot so I was wondering if someone can help me with the logic or code samples to achieve the following:

Adverts are to have 3 fields: Title, positive keywords and negative keywords.

I'm struggling to figure out how to select and then order the records where all adverts are returned but ordered as follows:

- Matches to the positive keywords come first in the list
- Non matches come second in the list
- Then all those with matches to the negative keywords come last

Any help would be greatly appreciated!

Many thanks

ben

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-12-17 : 10:32:57
What do you mean by Positive & negative keywords?

Some sample data and expected result would be helpful.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

ben21
Starting Member

5 Posts

Posted - 2006-12-17 : 13:55:44
Hi there Harsh - Its quite tricky to explain but I’ll do my best!

Its to search insurance policies so lets say we have two adverts both with “motor insurance” in the description but one has “teenage” in its negative keyword field.

So when someone searches with “pensioner motor insurance” BOTH policies are returned but the one with “teenage” in the negative field is returned last in the listing

There would only be one free-text search box on the web page so think of positive words as the normal description to search against and think of the negatives as words to weight the advert to a lower ranking.

Does that help?

Ben
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-12-18 : 03:52:56
have you thought about full text search?
the way you have it now can get quite complex...
for example how do you mark which word in your search is negative?



Go with the flow & have fun! Else fight the flow
blog thingie: http://weblogs.sqlteam.com/mladenp
Go to Top of Page
   

- Advertisement -