'How to run SQL Server full-text index in EF Core
I need to run SQL Server full-text index query in EF Core 6.0 as shown here:
SELECT *
FROM Products
WHERE CONTAINS(FullTextSearch, '"*glove*" AND "*yellow*" AND "*large*"');
After too much searching, I found some topics and solutions like these:
And finally, I wrote my query like this:
var searchCondition = string.Join(" AND ", words.Where(x => !string.IsNullOrEmpty(x)).Select(x => $"\"*{x}*\""));
DbContext.Products.Where(s => EF.Functions.Contains(s.FullTextSearch, searchCondition));
But the result it's not what I expected, it's the generated query:
SELECT TOP(@__p_1) [p].[Id], ...
FROM [Products] AS [p]
WHERE FREETEXT([p].[FullTextSearch], @__searchCondition_2)
I don't want to use FreeText - I need CONTAINS.
What do I have to do?
UPDATE: Everythings work very well and the problem was checking old version of the code.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
