简体   繁体   English

SQL Server 中的全文搜索

[英]Fulltext search in SQL Server

I'm trying to create a simple search page on my site but finding it difficult to get full text search working as I would expect it to word.我试图在我的网站上创建一个简单的搜索页面,但发现很难像我期望的那样进行全文搜索。

Example search:示例搜索:

select *
from Movies
where contains(Name, '"Movie*" and "2*"')

Example data:示例数据:

Id  Name
------------------
1   MyMovie 
2   MyMovie Part 2
3   MyMovie Part 3
4   MyMovie X2
5   Other Movie

Searches like "movie*" return no results since the term is in the middle of a work."movie*"这样的搜索不会返回任何结果,因为该术语位于作品的中间。

Searches like "MyMovie*" and "2*" only return MyMovie Part 2 and not MyMovie Part X2"MyMovie*" and "2*"这样的搜索只返回 MyMovie Part 2 而不是 MyMovie Part X2

It seems like I could just hack together a dynamic SQL query that will just and name like '%movie%' and name like '%x2%' and it would work better than full text search which seems odd since it's a large part of SQL but doesn't seem to work as good as a simple like usage.似乎我可以拼凑一个动态 SQL 查询,它只会and name like '%movie%' and name like '%x2%' ,它会比全文搜索更好用,因为它是 SQL 的很大一部分,所以看起来很奇怪但似乎不如简单的用法那么好。

I've turned off my stop list so the number and single character results appear but it just doesn't seem to work well for what I'm doing which seems rather basic.我已经关闭了我的停用列表,因此出现了数字和单个字符结果,但它似乎并不适合我正在做的事情,这看起来很基本。

select * from Movies where name like ('%Movie%') or name like ('%2%');从名称如 ('%Movie%') 或名称如 ('%2%') 的电影中选择 *;

select * from Movies where freetext(Name, ' "Movie*" or "2*" ')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM