How to concat several ts_vectors with new expression index from Npgsql 5?

Viewed 45

We using concatenation of ts_vectors to support multiple languages in some columns. In old versions it was like that:

public class AddTsVectorIndexes : Migration
{
    protected override void Up(MigrationBuilder migrationBuilder)
    {
        migrationBuilder.Sql(
            @"CREATE INDEX ""Name_TsVector"" ON ""SomeTable"" USING GIN
(((to_tsvector('russian', ""Name"") || to_tsvector('english', ""Name"")) || to_tsvector('simple', ""Name"")));");
    }

    protected override void Down(MigrationBuilder migrationBuilder)
    {
        migrationBuilder.Sql(@"DROP INDEX ""Name_TsVector"";");
    }
}

Is there any way to concat ts_vectors with new sugar syntax of expression index added in Npgsql 5(docs)?

Or maybe there is a way to create multilang ts_vector dictionary for parsers and just use it as config for creation ts_vectors and ts_query?

1 Answers

The sugar for creating full-text search indices is just that - sugar for the common usage. If you want anything else (like the above), you can very easily use raw SQL in your migrations instead, and specify whatever expression you want.

Related