全文结果和错误结果

ev7lccsx  于 2022-10-22  发布在  其他
关注(0)|答案(1)|浏览(99)

我在Article表上有一个完整的索引目录,定义如下:

create fulltext catalog [Article_Catalog]
go

create fulltext index on [Article] (ArticleId, ArticleIdTrimed, Designation, FlatVehicles, FlatCategories, FlatCriterias) key index [Article_id] on [Article_Catalog] with change_tracking = manual
go

alter fulltext index on [Article] start full population

以下是示例数据:


小时
我想搜索ArticleId022.465,但这样做时没有得到任何结果:

-- Query 
    Declare @q as varchar(50) = '022.4'

    declare @q2 varchar(50)
    set @q2 = isnull(@q, '')
    declare @ft varchar(50) 
    set @ft = '"' + @q2 + '"'

    select
        a.DataSupplierId,
        a.SupplierId,
        a.ArticleId
    from
        containstable(article, (
        ArticleId, 
        ArticleIdTrimed
        ), @ft) ftx
        inner join article a on a.id = ftx.[key]
    order by
        ftx.[rank] desc

但是,如果我搜索这个字符串,它是有效的:
Declare @q as varchar(50) = '022.465'
它的作用是:
Declare @q as varchar(50) = '022465'
我真的不明白为什么。。。

kknvjkwl

kknvjkwl1#

似乎您正在尝试进行前缀搜索,在搜索条件中添加*应该会为您提供所需的结果。

相关问题