Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggest using generated columns for Full-Text Search operations #3870

Open
laurenceisla opened this issue Jan 22, 2025 · 0 comments
Open

Suggest using generated columns for Full-Text Search operations #3870

laurenceisla opened this issue Jan 22, 2025 · 0 comments
Labels
docs Only related to documentation

Comments

@laurenceisla
Copy link
Member

Problem

Complex full-text search cannot be done directly on some cases. For example when using computed fields or if we want to do the FTS to multiple fields at the same time.

Our suggestion in the docs is not correct right now, since it won't use the index created there (#3845 won't fix this since it doesn't include computed fields).

Solution

According to the PostgreSQL docs, there is an option to use generated columns to achieve this:

Another approach is to create a separate tsvector column to hold the output of to_tsvector. To keep this column automatically up to date with its source data, use a stored generated column. This example is a concatenation of title and body, using coalesce to ensure that one field will still be indexed when the other is NULL

So we should suggest using this alternative in the docs.

@laurenceisla laurenceisla added the docs Only related to documentation label Jan 22, 2025
@steve-chavez steve-chavez changed the title Suggest using generated columns fot Full-Text Search operations Suggest using generated columns for Full-Text Search operations Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Only related to documentation
Development

No branches or pull requests

1 participant