3

I have this:

SELECT * FROM AwesomePeople WHERE CONTAINS(Name, 'NEAR(("Nathan", "Fillion"), MAX, TRUE)')

But I want to combine it so it uses my thesaurus of words to look at alternatives for Nathan and Fillion.

I can do this:

SELECT * FROM AwesomePeople WHERE CONTAINS(Name, 'FORMSOF (THESAURUS, "Nathan"))

But I don't know how to search for 2 words, or make it do FORMSOF and NEAR together in a single query. I have tried a few combinations but am out of luck.

Any ideas?

NibblyPig
  • 51,118
  • 72
  • 200
  • 356

2 Answers2

2

It looks like you are using SQL Server 2012 as 'NEAR(("Nathan", "Fillion") is the newer form of proximity search, called custom proximity search.

From technet: http://technet.microsoft.com/en-us/library/ms142568%28v=sql.110%29.aspx

You cannot combine a custom proximity term with a generic proximity term (term1 NEAR term2), a generation term (ISABOUT …), or a weighted term (FORMSOF …).

and also lower down

You cannot combine a generic proximity term with a custom proximity term, such as NEAR((term1,term2),5), a weighted term (ISABOUT …), or a generational term (FORMSOF …).

Technet seems to have the ISABOUT and FORMSOF mixed up in the first quote, but either way ISABOUT or FORMSOF terms cannot be combined with a NEAR term.

cabbagetreecustard
  • 647
  • 2
  • 13
  • 22
2

Following will work great. It is more powerful.

SELECT  * FROM AwesomePeople AS C INNER JOIN
CONTAINSTABLE(AwesomePeople ,name, 'ISABOUT (
    FORMSOF(Thesaurus, "Nathan"),
    FORMSOF(Thesaurus, "Fillion"))') AS K
ON C.ID = K.[KEY];
gawi
  • 2,843
  • 4
  • 29
  • 44