Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / Other Technologies / Full-Text Search / September 2006

Tip: Looking for answers? Try searching our database.

conditionally query a catalogue's field

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mark.brady@reedbusiness.com.au - 11 Sep 2006 03:37 GMT
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
Hilary Cotter - 11 Sep 2006 13:53 GMT
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.

Signature

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

>I have recently used the 'top_n_by_rank' clause in a full text
> query in order to reduce the query execution time.
[quoted text clipped - 29 lines]
>
> Thanks
Simon Sabin - 12 Sep 2006 00:18 GMT
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

> I have recently used the 'top_n_by_rank' clause in a full text query
> in order to reduce the query execution time.
[quoted text clipped - 27 lines]
>
> Thanks
mark.brady@reedbusiness.com.au - 12 Sep 2006 22:48 GMT
Thank you for your replies to my post.
This was exactly what I was after.

Many Thanks

Mark
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.