Opened 8 years ago
Last modified 10 days ago
#28041 assigned New feature
Postgres prefix searching for full text search
Description ¶
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))
According to the ticket's flags, the next step(s) to move this issue forward are:
- For a Django committer to do a final review of the patch and merge it if all looks good.
Change History (13)
comment:1 by , 8 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 8 years ago
Component: | Uncategorized → contrib.postgres |
---|---|
Type: | Uncategorized → New feature |
comment:3 by , 8 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:4 by , 8 years ago
Has patch: | set |
---|
comment:5 by , 8 years ago
Needs documentation: | set |
---|---|
Needs tests: | set |
comment:6 by , 4 years ago
Needs documentation: | unset |
---|---|
Needs tests: | unset |
Owner: | changed from | to
comment:7 by , 4 years ago
Patch needs improvement: | set |
---|
comment:8 by , 3 years ago
Owner: | removed |
---|---|
Status: | assigned → new |
comment:9 by , 5 months ago
Cc: | added |
---|
comment:10 by , 5 months ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:11 by , 6 weeks ago
Needs tests: | set |
---|
comment:12 by , 6 weeks ago
Needs documentation: | set |
---|
comment:13 by , 10 days ago
Needs documentation: | unset |
---|---|
Needs tests: | unset |
Patch needs improvement: | unset |
Triage Stage: | Accepted → Ready for checkin |
(Heads up there are several co-authors here we should try to preserve when squashing.)
Additional input would be appreciated on this question about whether to make low-level assertions against as_sql()
. I don't mind the current approach. I'm a little concerned that the alternative--structuring test data so that search results will prove that an input has been escaped--will be difficult and fragile to maintain, but maybe there's a way to do it.
PR