Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Full-Text-Search in order to find partial words (SQL Server 2008)

I'm trying to build a facebook like search for my software.

I'd like to query the table customers.

I've set up a FULLTEXT Index and tried the next query

SELECT * FROM Customer where CONTAINS(*,'*ann*') 

The query does return all the customers named Ann, but it doesn't return all the customers name Anne.

Is there a way to create prefix search on SQL Server 2008 using FTS?

like image 544
Dig Avatar asked Jun 03 '10 01:06

Dig


People also ask

How does Full-Text Search work in SQL Server?

Full-text queries perform linguistic searches against text data in full-text indexes by operating on words and phrases based on the rules of a particular language such as English or Japanese. Full-text queries can include simple words and phrases or multiple forms of a word or phrase.

How do I enable Full-Text Search in SQL?

SQL Server databases are full-text enabled by default. Before you can run full-text queries, however, you must create a full text catalog and create a full-text index on the tables or indexed views you want to search.

How do you implement Full-Text Search?

To implement a full-text search in a SQL database, you must create a full-text index on each column you want to be indexed. In MySQL, this would be done with the FULLTEXT keyword. Then you will be able to query the database using MATCH and AGAINST.


1 Answers

I've found a solution to my problem. The query should be:

select * from Customers where contains(*, '"ann*"') 

The quotes are the important part.

like image 200
Dig Avatar answered Oct 10 '22 11:10

Dig