我正在AdventureWorks數據庫中進行全文搜索。在production.ProductDescription我試圖搜索「山」和「替換」。是否可以在單個CONTAINSTABLE搜索條件中組合拐點和鄰近搜索?
我知道有一個與下面的描述中記載:
High-performance mountain replacement wheel.
我先去周圍是這樣的:
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;
這返回0行。如果我將「附近的山地更換」改爲「附近的山地更換」,我會在結果數據集中獲得我期望的記錄。
我的下一個嘗試是嘗試像下面這樣:
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;
,但是這會產生錯誤
Syntax error near 'NEAR' in the full-text search condition 'FORMSOF(INFLECTIONAL, "replacements") NEAR "mountain"'.
我看看文法CONTAINSTABLE和事實證明,你可以在相同的搜索條件下沒有generation_term(例如FORMSOF())和接近性項(例如NEAR)。
添加以下記錄表中:
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;
對於這個人爲的例子,我希望用戶能夠提供搜索te有價證券交易所山和替代品,並返回記錄相對較高的排名記錄,其中包含替換和山峯彼此靠近,但在如何到達那裏是一個損失。