Sql-server – SQL Server Fulltext search not finding the rows

full-text-searchsql serversql-server-2008

I have a SQL Server table and I'm trying to make sense of fulltext searching 🙂

I have set up a fulltext catalog and a fulltext index on a table Entry, which contains among other columns a VARCHAR(20) column called VPN-ID.

There are about 200'000 rows in that table, and the VPN-ID column has values such as:

VPN-000-359-90
VPN-000-363-85
VPN-000-362-07
VPN-000-362-91
VPN-000-355-55
VPN-000-368-36
VPN-000-356-90

Now I'm trying to find rows in that table with a fulltext enabled search.

When I do

SELECT (list of columns)
FROM dbo.Entry
WHERE CONTAINS(*, 'VPN-000-362-07')

everything's fine and dandy and my rows are returned.

When I start searching with a wildcard like this:

SELECT (list of columns)
FROM dbo.Entry
WHERE CONTAINS(*, 'VPN-000-362-%')

I am getting results and everything seems fine.

HOWEVER: when I searching like this:

SELECT (list of columns)
FROM dbo.Entry
WHERE CONTAINS(*, 'VPN-000-36%')

suddenly I get no results back at all….. even though there are clearly rows that match that search criteria…

Any ideas why?? What other "surprises" might fulltext search have in store for me? 🙂

Update: to create my fulltext catalog I used:

CREATE FULLTEXT CATALOG MyCatalog WITH ACCENT_SENSITIVITY = OFF

and to create the fulltext index on my table, I used

CREATE FULLTEXT INDEX 
ON dbo.Entry(list of columns)
KEY INDEX PK_Entry

I tried to avoid any "oddball" options as much a I could.

Update #2: after a bit more investigation, it appears as if SQL Server Fulltext search somehow interprets my dashes inside the strings as separators….

While this query returns nothing:

SELECT (list of columns)
FROM dbo.Entry
WHERE CONTAINS(*, '"VPN-000-362*"')

this one does (splitting up the search term on the dashes):

SELECT (list of columns)
FROM dbo.Entry
WHERE CONTAINS(*, ' "VPN" AND "000" AND "362*"')

OK – seems a bit odd that a dash appears to result in a splitting up that somehow doesn't work…..

Best Answer

which Language for Word Breaker do you use? Have you tried Neutral?

enter image description here

EDIT:
in adition you should use WHERE CONTAINS([Column], '"text*"'). See MSDN for more information on Prefix Searches:

C. Using CONTAINS with

The following example returns all product names with at least one word starting with the prefix chain in the Name column.

USE AdventureWorks2008R2;
GO
SELECT Name
FROM Production.Product
WHERE CONTAINS(Name, ' "Chain*" ');
GO

btw ... similar question here and here