This question is about SQL Server's FTS ContainsTable.
To replicate the issue, we can use the script below which will create one table and fill it with addresses.
CREATE TABLE Address (FullAddress nvarchar(100) NOT NULL);
CREATE UNIQUE CLUSTERED INDEX AddressKey ON Address(FullAddress);
INSERT INTO Address VALUES ('1 OLD YONGE ST, AURORA, ON');
INSERT INTO Address VALUES ('1 OLD YONGE ST, NORTH YORK, ON');
INSERT INTO Address VALUES ('1 YONGE ST N UNIT 1, HUNTSVILLE, ON');
INSERT INTO Address VALUES ('1 YONGE ST N UNIT 10, HUNTSVILLE, ON');
INSERT INTO Address VALUES ('18 YONGE ST UNIT 324, TORONTO, ON');
INSERT INTO Address VALUES ('10415 YONGE ST UNIT 1, RICHMOND HILL, ON');
INSERT INTO Address VALUES ('11211 YONGE ST UNIT 37 BUILDING A, RICHMOND HILL, ON');
Now we will create the fulltext catalog and create an index on it.
CREATE FULLTEXT CATALOG AddressCat;
CREATE FULLTEXT INDEX ON Address(FullAddress) KEY INDEX AddressKey ON AddressCat;
Issue
If we run a query and search for addresses that start with 1 (Notice this is a single digit) and the 1 is NEAR
the next term which is Yong, we expect it to return all the first 4 records above. Here is the query:
SELECT * FROM CONTAINSTABLE (Address, FullAddress, '"1" NEAR "Yon*"') ORDER BY RANK DESC;
However, it returns no rows. This is the issue.
But what if we execute a query with double digits such as 11 or 10, then it will return records as expected.
Question:
Why will ContainsTable
NOT return any results for single digit searches?