Postgres prefix searching for full text search
I've needed prefix matching in full text search. As in #27899, It would be nice to add a RawSearchQuery
, but also to have it accept a Lexeme
so your query might look something like
Dog.objects.annotate(search=SearchVector('name')).filter(search=RawSearchQuery(Lexeme('opt', prefix=True)))
and combine Lexeme
s together either ANDing, ORing instead of just letting the user specify the query as a postgres string (https://www.postgresql.org/docs/9.6/static/datatype-textsearch.html#DATATYPE-TSQUERY)
Dog.objects.annotate(search=SearchVector('name')).filter(search=RawSearchQuery(Lexeme('opt', prefix=True) + Lexeme('blah', invert=True))
Change History
(10)
Owner: |
changed from nobody to Joe Tsoi
|
Status: |
new → assigned
|
Component: |
Uncategorized → contrib.postgres
|
Type: |
Uncategorized → New feature
|
Triage Stage: |
Unreviewed → Accepted
|
Needs documentation: |
set
|
Needs tests: |
set
|
Needs documentation: |
unset
|
Needs tests: |
unset
|
Owner: |
changed from Joe Tsoi to Karl Hobley
|
Patch needs improvement: |
set
|
Owner: |
Karl Hobley removed
|
Status: |
assigned → new
|
Owner: |
set to Calvin Vu
|
Status: |
new → assigned
|
PR