Opened 8 years ago
Closed 6 years ago
#27899 closed New feature (fixed)
Phrase search query for Postgres full text search
Reported by: | Ilya Semenov | Owned by: | Greg Allensworth |
---|---|---|---|
Component: | contrib.postgres | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Postgres 9.6 now supports phrase search with ... @@ phraseto_tsquery('hello world')
. It would be great if Django supported it natively.
Currently, django.contrib.postgres.search.SearchQuery
hard-codes SQL lookup formatting:
class SearchQuery(SearchQueryCombinable, Value): def as_sql(self, compiler, connection): ... template = 'plainto_tsquery({}::regconfig, %s)'.format(config_sql)
I believe the lookup function should be taken from a class level variable instead, and two more classes should be introduced: PhraseSearchQuery
using phraseto_tsquery
, and RawSearchQuery
using to_tsquery
.
Change History (22)
comment:1 by , 8 years ago
Component: | Uncategorized → contrib.postgres |
---|---|
Triage Stage: | Unreviewed → Accepted |
Version: | 1.10 → master |
comment:2 by , 8 years ago
comment:4 by , 8 years ago
Needs documentation: | set |
---|---|
Patch needs improvement: | set |
Release notes and documentation needed.
comment:5 by , 8 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:7 by , 7 years ago
Patch needs improvement: | unset |
---|---|
Triage Stage: | Accepted → Ready for checkin |
comment:8 by , 7 years ago
Triage Stage: | Ready for checkin → Accepted |
---|
"Ready for checkin" is set by a patch reviewer, not the patch author (see Triaging tickets).
comment:10 by , 7 years ago
Patch needs improvement: | set |
---|
comment:11 by , 6 years ago
Hello. I wanted to check in on the status of this patch, to support phraseto_tsquery()
I ask because this one has been idle for about 14 months, in a "needs improvement" state.
I have come up with a much simpler approach to allowing phrase searching, and would be glad to generate a pull request.
comment:12 by , 6 years ago
Sorry I don't have a free time for a long time, yes sure you can reuse my PR or create you own, if you need any help please let me know.
comment:13 by , 6 years ago
Owner: | changed from | to
---|
My own internal note: I have a copy of the patched version here. https://github.com/GreenInfo-Network/Django-PostgreSQL-SearchVector
comment:15 by , 6 years ago
Thanks, Andrii. Do you want to go ahead and close PR 8491 https://github.com/django/django/pull/8491 ?
I will open a new one later today, or tomorrow.
comment:17 by , 6 years ago
Patch needs improvement: | unset |
---|
Unchecking Patch needs improvement
so your patch is back in the review queue.
comment:20 by , 6 years ago
Patch needs improvement: | set |
---|
The patch may need a small change to support "to_tsquery" which is a part of PR 8491. Maybe a multivalued argument called something like search_type
with values like "raw", "phrase", "plain" would be appropriate.
comment:21 by , 6 years ago
Patch needs improvement: | unset |
---|
I need also this feature in my project, I'm going to start working on PR.