简体   繁体   中英

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.

Searches like "MyMovie*" and "2*" only return MyMovie Part 2 and not 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.

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%');

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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