2 つの検索を一緒に AND したいと思います。たとえば、テキスト「foo」を含み、カテゴリが「Automotive Repair」のすべてのドキュメントを検索します。
おそらく、追加データを全文にする必要はなく、単に = などを使用できますか? 追加データがかなり小さい場合、全文の複雑さを保証できない場合があります。
ただし、両方でフル テキストを使用する場合は、結果をまとめて取得するストアド プロシージャを使用します。ここでの秘訣は、結果セットをすぐに返そうとするのではなく、結果をステージングすることです。
これは大まかな出発点です。
-- a staging table variable for the document results
declare @documentResults table (
Id int,
Rank int
)
insert into @documentResults
select d.Id, results.[rank]
from containstable (documents, (text), '"foo*"') results
inner join documents d on results.[key] = d.Id
-- now you have all of the primary keys that match the search criteria
-- whittle this list down to only include keys that are in the correct categories
-- a staging table variable for each the metadata results
declare @categories table (
Id int
)
insert into @categories
select results.[KEY]
from containstable (Categories, (Category), '"Automotive Repair*"') results
declare @topics table (
Id int
)
insert into @topics
select results.[KEY]
from containstable (Topics, (Topic), '"Automotive Repair*"') results
declare @areas table (
Id int
)
insert into @areas
select results.[KEY]
from containstable (Areas, (Area), '"Automotive Repair*"') results
select d.text, c.category, t.topic, a.area
from @results r
inner join documents d on d.Id = r.Id
inner join @categories c on c.Id = d.CategoryId
inner join @topics t on t.Id = d.TopicId
inner join @areas a on a.Id = d.AreaId