all groups > sql server full text search > september 2006 >
You're in the

sql server full text search

group:

conditionally query a catalogue's field


conditionally query a catalogue's field mark.brady NO[at]SPAM reedbusiness.com.au
9/10/2006 7:37:32 PM
sql server full text search:
I have recently used the 'top_n_by_rank' clause in a full text
query in order to reduce the query execution time.

Here is the senario - we have a table called 'article' that has
three fields.
ID int,
Active bit,
Body varchar(8000)

I want use the top_n_by_rank clause to only return the top 10 articles.
Simple enough but out of the top 10 articles returned only 2 of those
were active.
Is there a way to conditionally query a catalogue field?

My FT query is below:

SELECT
*
FROM
Article AS FT_TBL
INNER JOIN CONTAINSTABLE(Article,
Body,
@vchQuery,
10
) AS KEY_TBL ON FT_TBL.ID = KEY_TBL.[KEY]
WHERE
FT_TBL.Active = 1

This seems to return the top 10 articles from the catalogue then
filters based on the where clause. I would like it to filter before
doing the FT search.

Thanks
Re: conditionally query a catalogue's field Hilary Cotter
9/11/2006 8:53:27 AM
Full text index an indexed view. Have the view only show you the rows where
active=2. This is only available in SQL 2005. In SQL 2000 you would have to
partition the table into child tables where one of the child tables would
only have rows where the status column is 2.

--
Hilary Cotter
Director of Text Mining and Database Strategy
RelevantNOISE.Com - Dedicated to mining blogs for business intelligence.

This posting is my own and doesn't necessarily represent RelevantNoise's
positions, strategies or opinions.

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



[quoted text, click to view]

Re: conditionally query a catalogue's field Simon Sabin
9/11/2006 11:18:39 PM
Hello mark,

Or add the active status to your indexed column, this could be done with
an indexed column in SQL 2005 as logn as its persisted. In SQL 2000 you will
have to update the body when the active status changes

and then include in the query

SELECT*
FROM Article AS FT_TBL
INNER JOIN CONTAINSTABLE(Article, Body,'<some query> AND TOKEN_ISACTIVE',
10) AS KEY_TBL ON FT_TBL.ID = KEY_TBL.[KEY]




Simon Sabin
SQL Server MVP
http://sqlblogcasts.com/blogs/simons


[quoted text, click to view]

Re: conditionally query a catalogue's field mark.brady NO[at]SPAM reedbusiness.com.au
9/12/2006 2:48:02 PM
Thank you for your replies to my post.
This was exactly what I was after.

Many Thanks

Mark
AddThis Social Bookmark Button