I want to make a query to retrieve people with NEAR syntax. When I search whatever text that contains letter N in second word, the result is always empty.
I have two people Ricardo registred on table, "Ricardo Mova" and "Ricardo Nova". If a search 'Ricardo NEAR "Mova*"' it's OK, but not for 'Ricardo NEAR 'Nova*'
EDIT
Table:
CREATE TABLE [dbo].[EntitySearch](
[IdEntity] [int] NOT NULL,
[Name] [nvarchar](max) NULL,
[Accessibility] [bit] NOT NULL,
[Document] [nvarchar](max) NULL,
[Email] [nvarchar](max) NULL,
[Phone] [nvarchar](max) NULL,
[Phone2] [nvarchar](max) NULL,
[Birthdate] [datetime] NULL,
[Gender] [int] NULL,
[IsAct] [bit] NOT NULL,
[Discriminator] [int] NOT NULL,
CONSTRAINT [PK_dbo.EntitySearch] PRIMARY KEY CLUSTERED
(
[IdEntity] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
Catalog
CREATE FULLTEXT CATALOG main_catalog;
Full Index
CREATE FULLTEXT INDEX ON dbo.EntitySearch
( [Name]
Language[Brazilian],
[Document]
Language[Brazilian],
[Email]
Language[Brazilian],
[Phone]
Language[Brazilian],
[Phone2]
Language[Brazilian] )
KEY INDEX [PK_dbo.EntitySearch] ON main_catalog;
Query:
SELECT top 10
FT_TBL.[IdEntity]
,FT_TBL.[Name]
,FT_TBL.[Accessibility]
,FT_TBL.[Document]
,FT_TBL.[Email]
,FT_TBL.[Phone]
,FT_TBL.[Phone2]
,FT_TBL.[Birthdate]
,FT_TBL.[Gender]
,FT_TBL.[IsAct]
,FT_TBL.[Discriminator]
FROM [EntitySearch] AS FT_TBL INNER JOIN
CONTAINSTABLE ([EntitySearch], [Name], 'Ricardo NEAR "Nova*"' ) AS KEY_TBL
ON FT_TBL.[IdEntity] = KEY_TBL.[KEY]
WHERE
FT_TBL.[IsAct] = 1
and FT_TBL.[Discriminator] = 2
and KEY_TBL.RANK > 10
ORDER BY KEY_TBL.RANK DESC, FT_TBL.[Name]
I expect that show 1 record, but none is showed. Thanks!
EDIT: WORKAROUND
I dropped and recriated the full text index with PORTUGUESE language. The problem has gone, so I guess the "bug" is on Brazilian language for index.
This is not a BUG.
Each langue has your self stop word list, which means that some words are irrelevant for the index search.
SELECT *
FROM sys.fulltext_system_stopwords
WHERE language_id = 1046 --Brazilian language ID
So, in my case, I did an algorithm that corrects the search query before sending.