tortoise-orm
tortoise-orm copied to clipboard
Postgresql tsvector field and query support
Have you considered support for Postgresql's tsvector type? ( https://www.postgresql.org/docs/12/textsearch.html )
I realize this would be entirely Postgresql specific so perhaps it would be more appropriate as a contrib module than a core feature.
I have been looking at implementing it and had a few different ideas; something like this perhaps:
- custom Field which creates a tsvector column type
- meta-field listing in a Model to describe which columns to full-text index
- Add a
CREATE TRIGGER
to the schema generation for each tsvector field. For each insert to the table, invoke tsvector_update_trigger ( https://www.postgresql.org/docs/12/functions-textsearch.html ) for the new row to create the vector on the fields listed by your meta-field. This is the thing I'm least sure about; should this be implemented in Tortoise, or just use the database trigger to manage it? - custom query Function which allows for the '@@ tsquery' syntax
One thing that Tortoise is missing is that it does not appear to be possible to tell Tortoise what index type you'd like when specifying to index a column; you would want to index the tsvector columns with either GIST or GIN depending on user requirements.