[8.x] Implement Full-Text Search for PostgreSQL #40229
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I worked with @driesvints on a basic api for the query builder to do fulltext searching (#40129). Based on the agreed api and his implementation for MySQL, I was able to easily add PostgreSQL support:
PostgreSQL has the great functionality that you can fine tune fulltext-search very much. For the moment, I only implemented the different search-term parsers to keep the pull request small. You will have access to the following search-term modes:
mode = 'plain'
: The plainto_tsquery function will transform a search string by and-ing the search terms: plainto_tsquery('english', 'The Fat Rats door') --> must match 'fat' & 'rat' & 'door'mode = 'phraseto'
: The phraseto_tsquery function will transform a search string by needing the phrases to appear in the exact order one after another: phraseto_tsquery('english', 'The Fat Rats door') --> must match 'fat' <-> 'rat' <-> 'door'mode = 'websearch'
: The websearch_to_tsquery function is mostly like MySQL's boolean search mode, which allows positive/negative operators in the text. But contrary to MySQL the terms are combined with and instead of or: websearch_to_tsquery('english', 'fat +rat -door') --> must match 'fat' & 'rat' & !'door'The websearch mode
mode = 'websearch'
is only available in PostgreSQL 11+ so the standard mode has been set tomode = 'plain'
.In my pull request #39875 I added fulltext index support for PostgreSQL which was released with v8.75.0. I did not implement multiple columns as the there are different ways to build them and querying needs to use the same method as the index. With querying support now added, I also implemented multiple columns support.
This is a stacked Pull Request on #39875, i will rebase it to the
8.x
branch as soon as the pull request of @driesvints is merged.