Currently, `django.contrib.postgres.search.SearchQuery` hard-codes SQL
lookup formatting:
{{{#!python
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`.
--
Ticket URL: <https://code.djangoproject.com/ticket/27899>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* version: 1.10 => master
* component: Uncategorized => contrib.postgres
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/27899#comment:1>
Comment (by Andrii Soldatenko):
I need also this feature in my project, I'm going to start working on PR.
--
Ticket URL: <https://code.djangoproject.com/ticket/27899#comment:2>
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/8491 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/27899#comment:3>
* needs_better_patch: 0 => 1
* needs_docs: 0 => 1
Comment:
Release notes and documentation needed.
--
Ticket URL: <https://code.djangoproject.com/ticket/27899#comment:4>
* owner: nobody => Andrii Soldatenko
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/27899#comment:5>
* needs_docs: 1 => 0
Comment:
Added docs and tests.
--
Ticket URL: <https://code.djangoproject.com/ticket/27899#comment:6>
* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/27899#comment:7>
* stage: Ready for checkin => Accepted
Comment:
"Ready for checkin" is set by a patch reviewer, not the patch author (see
[https://docs.djangoproject.com/en/dev/internals/contributing/triaging-
tickets/ Triaging tickets]).
--
Ticket URL: <https://code.djangoproject.com/ticket/27899#comment:8>
Comment (by Andrii Soldatenko):
Sorry for that. Thanks for the link!
--
Ticket URL: <https://code.djangoproject.com/ticket/27899#comment:9>
* needs_better_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/27899#comment:10>
Comment (by Greg Allensworth):
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/27899#comment:11>
Comment (by Andrii Soldatenko):
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/27899#comment:12>
* owner: Andrii Soldatenko => Greg Allensworth
Comment:
My own internal note: I have a copy of the patched version here.
https://github.com/GreenInfo-Network/Django-PostgreSQL-SearchVector
--
Ticket URL: <https://code.djangoproject.com/ticket/27899#comment:13>
Comment (by Andrii Soldatenko):
You need to adopt your patch to django style and create docs and tests.
--
Ticket URL: <https://code.djangoproject.com/ticket/27899#comment:14>
Comment (by Greg Allensworth):
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/27899#comment:15>
Comment (by Greg Allensworth):
Pull Request is up: https://github.com/django/django/pull/10102
--
Ticket URL: <https://code.djangoproject.com/ticket/27899#comment:16>
* needs_better_patch: 1 => 0
Comment:
Unchecking `Patch needs improvement` so your patch is back in the review
queue.
--
Ticket URL: <https://code.djangoproject.com/ticket/27899#comment:17>
* needs_tests: 0 => 1
Comment:
However tests are missing.
--
Ticket URL: <https://code.djangoproject.com/ticket/27899#comment:18>
* needs_tests: 1 => 0
Comment:
I added a test to Greg's patch
[https://github.com/django/django/pull/10359 in this PR].
--
Ticket URL: <https://code.djangoproject.com/ticket/27899#comment:19>
* needs_better_patch: 0 => 1
Comment:
The patch may need a small change to support "to_tsquery" which is a part
of [https://github.com/django/django/pull/8491 PR 8491]. Maybe a
multivalued argument called something like `search_type` with values like
"raw", "phrase", "plain" would be appropriate.
--
Ticket URL: <https://code.djangoproject.com/ticket/27899#comment:20>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/27899#comment:21>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"f5e347a6402c1996a8f7063de4b314bae4a55683" f5e347a]:
{{{
#!CommitTicketReference repository=""
revision="f5e347a6402c1996a8f7063de4b314bae4a55683"
Fixed #27899 -- Added support for phrase/raw searching in SearchQuery.
Thanks Tim Graham, Nick Pope, and Claude Paroz for contribution and
review.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27899#comment:22>