【问题标题】:Integrate regular and full text index in SQL Server在 SQL Server 中集成常规索引和全文索引
【发布时间】:2011-03-25 05:40:01
【问题描述】:

我在 SQL Server 中有一个包含以下列的表:

id int (primary key)
text nvarchar(max) (full text indexed)
type int

我有这样的疑问:

where Contains([text], @text)

where Contains([text], @text) AND [type] = 3

但是第二个查询很慢。我认为我应该将全文索引与 [type] 字段集成。

还有其他解决方案吗?

谢谢

【问题讨论】:

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


    【解决方案1】:

    我假设您没有运行 SQL 2008,因为该版本中的集成全文引擎应该为您的查询做出更好的决策。对于早期版本,我通过使用某种形式的自定义标签在文本中嵌入额外的键取得了成功。您需要一些触发器来使文本与键保持同步。

    例如,“这是我的示例文本。 TypeKey_3"

    然后你的 where 子句变成这样:

    where Contains([text], @text AND "TypeKey_" + @type)
    

    【讨论】:

      【解决方案2】:

      鉴于您无法将整数字段添加到全文索引,您最好的办法是向 [type] 添加常规索引。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-05-02
        • 1970-01-01
        • 1970-01-01
        • 2011-10-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多