I have a user table with a single column for a person’s name:
CREATE TABLE [dbo].[Users]
(
Id bigint NOT NULL,
Name nvarchar(80) NOT NULL,
PRIMARY KEY CLUSTERED (Id ASC)
)
The Name column can contain either a full name or just the first name or anything really (separated by spaces). In order to implement a search on Name, I would like to utilize SQL’s full-text search, but not sure if it’s suitable for searching names/nicknames and not actual words. Also the question is – which language do I choose when creating the FT index on Name?
Any other considerations?
Thank you.
It seems that if you want to search multi-part names, full-text search is the easiest and most appropriate approach (please correct me if I’m wrong). The other alternative being
LIKE '%query%', however it has too many disadvantages:So I went ahead and implemented a full-text search. My queries look something like this:
The only slight difficulty is that I had to convert user query (John) into a CONTAINS-friendly query (“John*”). To do that, I implemented this method in my UserRepository:
Hope this helps anyone stumbling into the same issue.
PS – I wrote a blogpost documenting this.