我的全文搜索查询有什么问题? [英] What's wrong with my fulltext search query?

查看:89
本文介绍了我的全文搜索查询有什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对全文CONTAINS运算符有一些问题。这里有一个快速的脚本来展示我在做什么。请注意,WAITFOR行只是简单地给全文索引一分钟完成填充。

  create table test1(id int constraint pk primary key,string nvarchar(100)not null); 
insert into test1 values(1,'dog')
insert into test1 values(2,'dogbreed')
insert into test1 values(3,'dogbreedinfo')
insert到test1值(4,'dogs')
插入到test1值(5,'品种')
插入到test1值(6,'品种')
插入到test1值(7 ,'breeddogs')


创建全文目录cat1
在test1上创建全文索引(字符串)在cat1上创建全文索引$ cat
waitfor delay '00:00: 03'
go
select * from test1 where contains(string,'* dog *')

go
drop table test1
drop fulltext目录cat1

返回的结果集为:

  1 dog 
2 dogbreed
3 dogbreedinfo
4 dogs

为什么记录#7'breeddogs'没有被返回?

编辑



有没有另外一种方法我应该搜索包含在另一个字符串中呃弦?一种比LIKE'%searchword%'更快的方法?

解决方案

仅仅因为MS全文搜索不支持后缀搜索 - 只有前缀,即* * *之前的'*'被忽略。这在联机丛书中有明确的说明。


CONTAINS可以搜索:


  • 一个单词或短语 li>
  • 单词或短语的前缀。

  • 靠近另一个单词的单词

  • 另一个词(例如drive这个单词就是驱动器的驱动器,驱动器,驱动器和驱动器的变形词)。
  • 一个单词,是使用同义词库的另一个单词的同义词(例如,金属词可以具有铝和钢的同义词)。

前缀术语的定义类似于这:


<前缀术语> :: = {word *| phrase *}


不幸的是:在全文搜索中无法发布LIKE搜索。 $ b

I'm have some trouble with the fulltext CONTAINS operator. Here's a quick script to show what I'm doing. Note that the WAITFOR line simply gives the fulltext index a moment to finish filling up.

create table test1 ( id int constraint pk primary key, string nvarchar(100) not null );
insert into test1 values (1, 'dog')
insert into test1 values (2, 'dogbreed')
insert into test1 values (3, 'dogbreedinfo')
insert into test1 values (4, 'dogs')
insert into test1 values (5, 'breeds')
insert into test1 values (6, 'breed')
insert into test1 values (7, 'breeddogs')

go
create fulltext catalog cat1
create fulltext index on test1 (string) key index pk on cat1
waitfor delay '00:00:03' 
go
select * from test1 where contains (string, '"*dog*"')

go
drop table test1
drop fulltext catalog cat1

The result set returned is:

1   dog
2   dogbreed
3   dogbreedinfo
4   dogs

Why is record #7 'breeddogs' not returned?

EDIT

Is there another way I should be searching for strings that are contained in other strings? A way that is faster than LIKE '%searchword%' ?

解决方案

Just because MS Full-Text search does not support suffix search - only prefix, i.e. '* ' in front of '*dog *' is simply ignored. It is clearly stated in Books Online btw.

CONTAINS can search for:

  • A word or phrase.
  • The prefix of a word or phrase.
  • A word near another word.
  • A word inflectionally generated from another (for example, the word drive is the inflectional stem of drives, drove, driving, and driven).
  • A word that is a synonym of another word using a thesaurus (for example, the word metal can have synonyms such as aluminum and steel).

Where prefix term is defined like this:

< prefix term > ::= { "word *" | "phrase *" }

So, unfortunately: there's no way to issue a LIKE search in fulltext search.

这篇关于我的全文搜索查询有什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆