Postgresql tsvector field and query support
See original GitHub issueHave 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.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:17 (7 by maintainers)
Top Results From Across the Web
Documentation: 15: 8.11. Text Search Types - PostgreSQL
The tsvector type represents a document in a form optimized for text search; the tsquery type similarly represents a text query.
Read more >Possible reason to include a tsvector field? - Stack Overflow
I have used the FTS capabilities in Postgres quite a bit, trigram, soundex, etc, too, and while it does work, we eventually decided...
Read more >Mastering PostgreSQL Tools: Full-Text Search and Phrase ...
to_tsvector for creating a list of tokens (the tsvector data type, where ts stands for "text search");; to_tsquery for querying the vector ...
Read more >Understanding PostgreSQL Full Text Search: 10 Critical Aspects
PostgreSQL Full Text Search also supports dictionaries that allow ... ALTER TABLE se_details ADD COLUMN ts tsvector GENERATED ALWAYS AS ...
Read more >PostgreSQL® Full-Text Search - Instaclustr
The most comprehensive guide on how to master the PostgreSQL ... Once the tsvector column is set up, it can be used in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
A special filter makes sense. I’m quite sick at the moment (and thinking is difficult), so I won’t get to anything soon. Possibly @abondar can help in the mean time if you want to attempt it?
I found that Postgres 12 added auto-generated and saved tsvectors: https://pgdash.io/blog/postgres-12-generated-columns.html. This could keep TsVectorField updated instead of using triggers. Seems like it almost fit into the generated_sql, but needs fields to compute from