SQL 服务器 FREETEXTTABLE 未返回结果
SQL Server FREETEXTTABLE not returning result
我使用 SQL 服务器 FREETEXTTABLE
功能在 table 列中搜索,基于用户输入的词,如搜索引擎和 return 最佳匹配行。
Table 列将包含许多问题,用户将在文本框中输入内容(以任何顺序),根据他输入的内容,我需要自动填充搜索页面。
我用了FREETEXTTABLE
。但它在某些情况下不起作用。
如果我输入 'what' 它不会 return 任何东西。
DECLARE @query VARCHAR(50) = 'what'
SELECT TOP 10 Questions
FROM tblQuestion tq
INNER JOIN FREETEXTTABLE(tblQuestion, Questions, @query) ft ON (tq.ID = ft.[Key])
ORDER BY ft.Rank DESC
但是如果我输入 'what is' 它 return 是 10 条记录。
DECLARE @query VARCHAR(50) = 'what is'
SELECT TOP 10 Questions
FROM tblQuestion tq
INNER JOIN FREETEXTTABLE(tblQuestion, Questions, @query) ft ON (tq.ID = ft.[Key])
ORDER BY ft.Rank DESC
我也试过CONTAINS
和FREETEXT
。
SELECT *
FROM tblQuestion
WHERE FREETEXT (Questions, 'what')
甚至这个查询 return 零行。
但是下面的查询 returned 几行。
SELECT *
FROM tblQuestion
WHERE FREETEXT (Questions, 'what is')
您可能是stop lists的受害者。使用以下查询确保所有单词都包含在索引中:
SELECT * FROM sys.dm_fts_index_keywords(DB_ID('YourDB'), OBJECT_ID('tblQuestion'))
注意:
A stopword can be a word with meaning in a specific language, or it
can be a token that does not have linguistic meaning. For example, in
the English language, words such as "a," "and," "is," and "the" are
left out of the full-text index since they are known to be useless to
a search.
如果您想包括所有单词,即使是标记为无用的单词,请使用以下代码:
ALTER FULLTEXT INDEX ON tblQuestion SET STOPLIST = OFF
我使用 SQL 服务器 FREETEXTTABLE
功能在 table 列中搜索,基于用户输入的词,如搜索引擎和 return 最佳匹配行。
Table 列将包含许多问题,用户将在文本框中输入内容(以任何顺序),根据他输入的内容,我需要自动填充搜索页面。
我用了FREETEXTTABLE
。但它在某些情况下不起作用。
如果我输入 'what' 它不会 return 任何东西。
DECLARE @query VARCHAR(50) = 'what'
SELECT TOP 10 Questions
FROM tblQuestion tq
INNER JOIN FREETEXTTABLE(tblQuestion, Questions, @query) ft ON (tq.ID = ft.[Key])
ORDER BY ft.Rank DESC
但是如果我输入 'what is' 它 return 是 10 条记录。
DECLARE @query VARCHAR(50) = 'what is'
SELECT TOP 10 Questions
FROM tblQuestion tq
INNER JOIN FREETEXTTABLE(tblQuestion, Questions, @query) ft ON (tq.ID = ft.[Key])
ORDER BY ft.Rank DESC
我也试过CONTAINS
和FREETEXT
。
SELECT *
FROM tblQuestion
WHERE FREETEXT (Questions, 'what')
甚至这个查询 return 零行。
但是下面的查询 returned 几行。
SELECT *
FROM tblQuestion
WHERE FREETEXT (Questions, 'what is')
您可能是stop lists的受害者。使用以下查询确保所有单词都包含在索引中:
SELECT * FROM sys.dm_fts_index_keywords(DB_ID('YourDB'), OBJECT_ID('tblQuestion'))
注意:
A stopword can be a word with meaning in a specific language, or it can be a token that does not have linguistic meaning. For example, in the English language, words such as "a," "and," "is," and "the" are left out of the full-text index since they are known to be useless to a search.
如果您想包括所有单词,即使是标记为无用的单词,请使用以下代码:
ALTER FULLTEXT INDEX ON tblQuestion SET STOPLIST = OFF