-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
feat: apply to_tsvector
to the filtered columns when a fts
operator is used
#3845
base: main
Are you sure you want to change the base?
Conversation
b9cee18
to
b8f8db2
Compare
b8f8db2
to
5e61a05
Compare
5e61a05
to
42b02b6
Compare
res = fromMaybe (unknownField fn jp) $ HM.lookup qi tables >>= | ||
Just . flip resolveTableFieldName fn | ||
Just . (\t -> resolveTableFieldName t fn toTsV) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a performance concern here: #2255 (comment)
I don't think there will be a difference in performance since it's using this lookup that is already applied for all filters before this PR.
42b02b6
to
846a45c
Compare
to_tsvector
to the filtered columns when a fts
operator is used
01a52f3
to
01aab5e
Compare
src/PostgREST/Plan/Types.hs
Outdated
@@ -20,6 +21,7 @@ import PostgREST.SchemaCache.Identifiers (FieldName) | |||
import Protolude | |||
|
|||
type TransformerProc = Text | |||
type ToTsVector = Maybe (Maybe Text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is confusing at first glance, why a double Maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, I created a new type to make it make sense.
docs/references/api/tables_views.rst
Outdated
@@ -193,7 +193,7 @@ The :code:`fts` filter mentioned above has a number of options to support flexib | |||
|
|||
curl "http://localhost:3000/tsearch?my_tsv=not.wfts(french).amusant" | |||
|
|||
Using `websearch_to_tsquery` requires PostgreSQL of version at least 11.0 and will raise an error in earlier versions of the database. | |||
This also works with columns of text and JSON types, converting them to ``tsvector`` accordingly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A subsection would be better for this. This way we can also highlight the feature on the release notes.
Maybe "automatic tsvector casting"`, "automatic to_tsvector??
01aab5e
to
9bffd08
Compare
… column, only if it's not of tsvector type
9bffd08
to
cb069ea
Compare
Closes #2255
When an
fts
operator is used, then it appliesto_tsvector
to the filtered column. For example:is equivalent to this in SQL:
If the `totsv` modifier (short for `to_tsvector`) is used for `fts` operators then it applies `to_tsvector` to the filtered column. For example:
Is equivalent to this in SQL: