I play in the AdventureWorks database with full text search. In production.ProductDescription I am trying to look for "mountains" and "replacements".
I know there is an entry with the following description:
High-performance mountain replacement wheel.
My first: this
SELECT
pd.Description,
ct.RANK
FROM Production.ProductDescription AS pd
INNER JOIN CONTAINSTABLE(
Production.ProductDescription,
Description,
'mountain NEAR replacements'
) AS ct ON pd.ProductDescriptionID = ct.[KEY]
ORDER BY ct.RANK DESC;
This returns 0 rows. If I change “replace mountain NEAR” to “replace mountain NEAR”, I get the record that I expect in the resulting dataset.
My next attempt was to try something like the following:
SELECT
pd.Description,
ct.RANK
FROM Production.ProductDescription AS pd
INNER JOIN CONTAINSTABLE(
Production.ProductDescription,
Description,
'FORMSOF(INFLECTIONAL, "replacements") NEAR "mountain"'
) AS ct ON pd.ProductDescriptionID = ct.[KEY]
ORDER BY ct.RANK DESC;
but it generates an error
Syntax error near 'NEAR' in the full-text search condition 'FORMSOF(INFLECTIONAL, "replacements") NEAR "mountain"'.
I reviewed the CONTAINSTABLE grammar and it turned out that you cannot have gener_term (e.g. FORMSOF ()) and an approximate term (e.g. NEAR) in the same search state.
I added the following entry to the table:
Replacement parts for you omg gee-whiz mountain
(96) fts:
SELECT
pd.Description,
ct.RANK
FROM Production.ProductDescription AS pd
INNER JOIN CONTAINSTABLE(
Production.ProductDescription,
Description,
'FORMSOF(INFLECTIONAL,"replacements") AND "mountain"'
) AS ct ON pd.ProductDescriptionID = ct.[KEY]
ORDER BY ct.RANK DESC;
, , (32) :
SELECT
pd.Description,
ct.RANK
FROM Production.ProductDescription AS pd
INNER JOIN CONTAINSTABLE(
Production.ProductDescription,
Description,
'"replacement" NEAR "mountain"'
) AS ct ON pd.ProductDescriptionID = ct.[KEY]
ORDER BY ct.RANK DESC;
, , , .