Is it possible to combine search in inflection and proximity in one state of the CONTAINSTABLE search?

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;

, , , .

+3
1

" , --"

"", .

Adventureworks , , , NEAR.

'FORMSOF(INFLECTIONAL, "replacement") AND FORMSOF(INFLECTIONAL, "mountain")' 

CONTAINSTABLE.

SELECT  
  pd.Description,  
  ct.RANK 
FROM Production.ProductDescription AS pd  
  INNER JOIN CONTAINSTABLE( 
    Production.ProductDescription,  
    Description,  
    'FORMSOF(INFLECTIONAL,"replacements") AND FORMSOF(INFLECTIONAL,"mountain")'  
  ) AS ct ON pd.ProductDescriptionID = ct.[KEY]      
ORDER BY ct.RANK DESC; 

, , , 96 , 32 . SQL Server 2005 , Product.ProductDescription.Description, .

, , , : . - 96 . - 48

+2

Source: https://habr.com/ru/post/1783751/


All Articles