需要帮助解决Sql Server全文搜索问题

时间:2022-08-26 11:58:53

I have a Full Text Catalog on single table, with three fields defined :-

我在单个表上有一个全文目录,定义了三个字段: -

TABLE: Animals
Fields: Name, Breed, LatinName.

Now, the Catalog seems to be working perfectly.

现在,目录似乎完美无缺。

eg.

CREATE FUNCTION AnimalSearch
(
    @Name NVARCHAR(200)
) RETURNS TABLE AS
RETURN 
(
    SELECT KEY_TBL.[Key] as Name,
        KEY_TBL.RANK as Relevance
    FROM CONTAINSTABLE(Animals, Name, @Name) AS KEY_TBL
)

Now, when i run this, i get the following results :- Name = ma (no results) Name = mat (no results) Name = matt (1 result - correct).

现在,当我运行这个时,我得到以下结果: - Name = ma(无结果)Name = mat(无结果)Name = matt(1结果 - 正确)。

SELECT * FROM [dbo].[AnimalSearch]('ma')

Is this the correct way to use this? I've also tried replacing CONTAINSTABLE with FREETEXTTABLE .. same thing .. no results.

这是使用它的正确方法吗?我也尝试用FREETEXTTABLE替换CONTAINSTABLE ......同样的事情......没有结果。

Any ideas, anyone?

任何想法,任何人?

Edit

I understand that this could be achieved in a stored proc. I'm was hoping to do this as a Table-Valued Function, so i could use this in some Linq2Sql. If it's really unperformant, then please say so.

我知道这可以在存储过程中实现。我希望这样做是一个表值函数,所以我可以在一些Linq2Sql中使用它。如果它真的没有意义,请说出来。

1 个解决方案

#1


Not sure it's a good idea. Table valued functions do not store statistics, so performance may suffer.

不确定这是个好主意。表值函数不存储统计信息,因此性能可能会受到影响。

#1


Not sure it's a good idea. Table valued functions do not store statistics, so performance may suffer.

不确定这是个好主意。表值函数不存储统计信息,因此性能可能会受到影响。