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
 General SQL Server Forums
 New to SQL Server Programming
 Sorting fulltext query results

Author  Topic 

pfdtv
Starting Member

10 Posts

Posted - 2008-07-30 : 14:04:38
Hi,
I just got the fulltext search features to work with SQL 2005 express. My question is, how do you sort the results based on the most relavant hit?
Here's my situation:
I am trying to search a total of 3 columns for each query and return the "ticket number". The first 2 columns ("summary", "description") come from a single table that contains the ticket numbers in a unique column (easy). The third column ("activities") comes from another table that maps to the first only through an arbitrary id number, so each ticket may contain multiple activities. I am currently just neglecting to display the activities (due to the non-uniqueness). My current code (included below) currently sorts the results just by ticket number. Is there a way to sort them based on the number of matches?

SELECT Ticket,Summary,Description
FROM table_one
WHERE CONTAINS(Summary, '"query"') OR
CONTAINS(Description, '"query"') OR
first_arbitrary_id IN (
SELECT second_arbitrary_id
FROM table_two
WHERE CONTAINS(Description, '"query"')
)

Thanks for your help.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-30 : 14:09:46
If you're looking ordering based on how close the string match to the fields, you could probably have a look at CONTAINSTABLE which also returns rank specifying closeness of value being search with field value.
Go to Top of Page
   

- Advertisement -