Npgsql: Correctly performing a full text search using an expression index

Npgsql docs suggest performing a full text search based on an expression index using ToTsVector

.Where(p => EF.Functions.ToTsVector("english", p.Title + " " + p.Description).Matches("Npgsql"))

As I've come to understand expression indexes, they require the query to include an identical expression as was used to create the index. In the docs this is ""Name"" || ' ' || ""Description"".

However it seems to me that p.Title + " " + p.Description would be evaluated before being translated to SQL as ToTsVector takes a plain string:

public static NpgsqlTsVector ToTsVector(this DbFunctions _, string config, string document);

Am I wrong or will the index not be utilized? If I am not wrong, is there some way to query correctly other than by using raw SQL?



Read more here: https://stackoverflow.com/questions/65702929/npgsql-correctly-performing-a-full-text-search-using-an-expression-index

Content Attribution

This content was originally published by lookuh at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: