我有一个平面表来执行全文搜索,即使是最简单的搜索也无法正常工作。我尝试过很多东西,但结果相同。令人惊讶的是,类似的全文搜索适用于同一数据库中的其他表。
下面是我的表结构,我还添加了全文索引详细信息以供快速参考。
以下是我的查询的搜索结果,我已经尝试了多个没有运气的东西,只有当我从列中提供精确值时,查询才有效。 即使我在查询中使用一列即Fname,搜索结果也是相同的。
我可能会遗漏一些基本的东西,但我不确定那是什么东西。下面是它的创建表脚本。
CREATE TABLE [dbo].[SampleTable](
[ID] [int] IDENTITY(1,1) NOT NULL,
[CID] [int] NOT NULL,
[VID] [int] NOT NULL,
[FID] [int] NOT NULL,
[TID] [int] NOT NULL,
[FName] [nvarchar](200) NOT NULL,
[IName] [nvarchar](200) NOT NULL,
[Contents] [nvarchar](max) NOT NULL,
[LatestVersion] [int] NOT NULL,
CONSTRAINT [PK_SampleTable] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'climate.c','climate_validate','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'flowrout.c','validateTreeLayout','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'flowrout.c','validateGeneralLayout','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'gage.c','gage_validate','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'gwater.c','gwater_validateAquifer','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'gwater.c','gwater_validate','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'lid.c','lid_validate','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'lid.c','validateLidProc','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'lid.c','validateLidGroup','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'link.c','link_validate','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'link.c','conduit_validate','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'link.c','pump_validate','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'link.c','orifice_validate','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'link.c','weir_validate','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'node.c','node_validate','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'node.c','divider_validate','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'project.c','project_validate','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'rdii.c','validateRdii','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'shape.c','shape_validate','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'snow.c','snow_validateSnowmelt','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'subcatch.c','subcatch_validate','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'table.c','table_validate','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'transect.c','transect_validate','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'climate.c','climate_validate','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'flowrout.c','validateTreeLayout','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'flowrout.c','validateGeneralLayout','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'gage.c','gage_validate','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'gwater.c','gwater_validateAquifer','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'gwater.c','gwater_validate','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'lid.c','lid_validate','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'lid.c','validateLidProc','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'lid.c','validateLidGroup','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'link.c','link_validate','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'link.c','conduit_validate','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'link.c','pump_validate','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'link.c','orifice_validate','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'link.c','weir_validate','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'node.c','node_validate','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'node.c','divider_validate','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'project.c','project_validate','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'rdii.c','validateRdii','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'shape.c','shape_validate','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'snow.c','snow_validateSnowmelt','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'subcatch.c','subcatch_validate','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'table.c','table_validate','',5);
insert into SampleTable (CID, VID, FID, TID, FName, IName, Contents, LatestVersion) values (-1,1,1,1,'transect.c','transect_validate','',5);
如果您需要更多详细信息,请与我们联系。
更新1: 因此,我进一步深入研究,发现类似于我的问题。
因此,如果正确理解这些URL,那么FreeTextTable不会对一个单词起作用,这肯定不正确,因为我在另一个表上使用一个单词查询并且它工作得很好。
答案 0 :(得分:0)
您正在尝试执行FreeTextTable不支持的子字符串匹配。相反,请将ContainsTable与通配符一起使用。
select * from ContainsTable(SampleTable, ([FName],[IName]), 'clima*')
此搜索将匹配以下字符串:
但赢了&#t> 匹配:
FYI FreeTextTable用于自然语言类型搜索 - 同义词,单数/复数形式,共轭匹配,搜索中只需要1个术语即可匹配。 ContainsTable匹配确切的单词(没有同义词等),允许布尔运算符(AND,OR,NOT),支持通配符(*,?),并且可以执行邻近搜索(word2的N个单词中的word1)。 / p>