【问题标题】:Sql FREETEXTTABLE with list searchkey带有列表搜索键的 Sql FREETEXTTABLE
【发布时间】:2018-06-13 21:31:58
【问题描述】:

看起来 FREETEXTTABLE 只是允许 searchkey 参数作为变量,像这样:

FROM FREETEXTTABLE(dbo.SampleTable, SampleColumn, @searchKey)

我有一个 searchKey 值列表,大约 50000 条记录,如何将 searchKey 表与 FREETEXTTABLE “JOIN”

我用过WHILE,但是很慢

DECLARE @results as table(
    Key NVARCHAR(100),
    Rank INT
)

declare @numberOfRows INT = SELECT MAX(Id) FROM dbo.SearchKeyTable)
declare @step int = (SELECT MIN(Id) FROM dbo.SearchKeyTable)

WHILE (@step <= @numberOfRows)
BEGIN
    declare @searchKey NVARCHAR(500) = (Select TOP(1) '''' + REPLACE([Description], '''', '"')  + ''' OR ''' + REPLACE([itemname], '''', '"') + '''' From dbo.SearchKeyTable where id = @step ORDER BY Id)

    insert into @results
    select [Key] as KeyId, SUM([Rank]) as TotalRank FROM FREETEXTTABLE(dbo.SampleTable, SampleColumn, @searchKey) GROUP BY [Key]

    SET @step = @step + 1
END

select * from @results

我的 dbo.SampleTable 表也很大,大约 1600 万条记录

【问题讨论】:

    标签: sql-server full-text-search freetexttable


    【解决方案1】:

    目前的解决方案:用c#多线程代替WHILE

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多