-1

I have the following stored proc :-

SELECT Id, Name
FROM FooBars
WHERE CONTAINS(Name, 'FORMSOF(Tesaurus, @query)')

Works fine when there is one word i the query: eg. foo* But it fails when I want to have more than one word which i'm trying to look for. eg. foo* bar* (this means any rows that have words that start with foo and start with bar).

What format does my @query argument need to look like, to enable multiple words for a Full Text Search with a Thesaurus?

Pure.Krome
  • 84,693
  • 113
  • 396
  • 647

1 Answers1

1

As far as I know, if you want to search for two or more expressions, you need to concatenate those with either AND, OR or NEAR, something like this (straight from Books Online):

USE AdventureWorks;
GO

SELECT Name
FROM Production.Product
WHERE CONTAINS(Name, '"chain*" OR "full*"');
GO

SELECT Description
FROM Production.ProductDescription
WHERE CONTAINS(Description, 'bike NEAR performance');
GO

SELECT Description
FROM Production.ProductDescription
WHERE ProductDescriptionID <> 5 AND
CONTAINS(Description, ' Aluminum AND spindle');

If and how that would work together with your FORMSOF(...) expression is unclear to me - but I'm sure you could quickly try that, no?

SELECT Id, Name
FROM FooBars
WHERE CONTAINS(Name, 'FORMSOF(THESAURUS, "foo*")'
    OR 'FORMSOF(THESAURUS, "bar*")')

Also make sure to spell "thesaurus" correctly in your FORMSOF () expression! :-)

Marc

Pure.Krome
  • 84,693
  • 113
  • 396
  • 647
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • I edited your post to fix the final SQL statement so it runs right. More comments after I spend some time making sure i'm getting back good results. – Pure.Krome Jun 04 '09 at 08:05