Search code examples
postgresqlherokufull-text-searchheroku-postgresheroku-cli

On Heroku Postgres, how to change full-text search dictionary?


I'm wanting to change the default_text_search_config of my "Hobby Basic Heroku Postgres" database. After running

heroku pg:psql and \dF,

I can see that Heroku has a preset stop dictionary that I want - Russian (pg_catalog.russian), so there is no need to create a new dictionary (although I see many questions about this as well).

According to the postgres docs, one can change this by altering the postgresql.conf, which is not applicable in this case, or by setting it for an individual session. I've tried setting it through the CLI with

SET default_text_search_config = 'pg_catalog.russian';

However, as soon as I exit the CLI, it reverts to the initial pg_catalog.english.

I'm using Prisma, so I've tried applying a migration of this as well, thinking that the issue was the session not persisting after I closed the CLI. This also was not successful.

Is there a way to do this?


Solution

  • It is also possible to set the default at the database level:

    If you are using the same text search configuration for the entire cluster you can use the value in postgresql.conf. To use different configurations throughout the cluster but the same configuration within any one database, use ALTER DATABASE ... SET. Otherwise, you can set default_text_search_config in each session.

    Assuming your database is called abcdefg, try the following:

    ALTER DATABASE abcdefg SET default_text_search_config TO 'pg_catalog.russian';
    

    I suspect this will work on Heroku's offering, but have not tried it.