[Django] #27899: Phrase search query for Postgres full text search

25 views
Skip to first unread message

Django

unread,
Mar 3, 2017, 8:33:57 AM3/3/17
to django-...@googlegroups.com
#27899: Phrase search query for Postgres full text search
-----------------------------------------+------------------------
Reporter: Ilya Semenov | Owner: nobody
Type: New feature | Status: new
Component: Uncategorized | Version: 1.10
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
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:

{{{#!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.

Django

unread,
Mar 3, 2017, 9:48:41 AM3/3/17
to django-...@googlegroups.com
#27899: Phrase search query for Postgres full text search
----------------------------------+------------------------------------

Reporter: Ilya Semenov | Owner: nobody
Type: New feature | Status: new
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+------------------------------------
Changes (by Simon Charette):

* version: 1.10 => master
* component: Uncategorized => contrib.postgres
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/27899#comment:1>

Django

unread,
Mar 31, 2017, 11:36:03 AM3/31/17
to django-...@googlegroups.com
#27899: Phrase search query for Postgres full text search
----------------------------------+------------------------------------

Reporter: Ilya Semenov | Owner: nobody
Type: New feature | Status: new
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+------------------------------------

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>

Django

unread,
May 11, 2017, 3:52:53 PM5/11/17
to django-...@googlegroups.com
#27899: Phrase search query for Postgres full text search
----------------------------------+------------------------------------

Reporter: Ilya Semenov | Owner: nobody
Type: New feature | Status: new
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+------------------------------------
Changes (by Andrii Soldatenko):

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/8491 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/27899#comment:3>

Django

unread,
May 12, 2017, 8:35:05 AM5/12/17
to django-...@googlegroups.com
#27899: Phrase search query for Postgres full text search
----------------------------------+------------------------------------

Reporter: Ilya Semenov | Owner: nobody
Type: New feature | Status: new
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
----------------------------------+------------------------------------
Changes (by Mads Jensen):

* 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>

Django

unread,
May 15, 2017, 4:20:47 PM5/15/17
to django-...@googlegroups.com
#27899: Phrase search query for Postgres full text search
-------------------------------------+-------------------------------------
Reporter: Ilya Semenov | Owner: Andrii
| Soldatenko
Type: New feature | Status: assigned

Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Andrii Soldatenko):

* owner: nobody => Andrii Soldatenko
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/27899#comment:5>

Django

unread,
May 18, 2017, 11:48:02 AM5/18/17
to django-...@googlegroups.com
#27899: Phrase search query for Postgres full text search
-------------------------------------+-------------------------------------
Reporter: Ilya Semenov | Owner: Andrii
| Soldatenko
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Andrii Soldatenko):

* needs_docs: 1 => 0


Comment:

Added docs and tests.

--
Ticket URL: <https://code.djangoproject.com/ticket/27899#comment:6>

Django

unread,
May 27, 2017, 7:25:29 AM5/27/17
to django-...@googlegroups.com
#27899: Phrase search query for Postgres full text search
-------------------------------------+-------------------------------------
Reporter: Ilya Semenov | Owner: Andrii
| Soldatenko
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Andrii Soldatenko):

* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/27899#comment:7>

Django

unread,
May 27, 2017, 8:27:51 AM5/27/17
to django-...@googlegroups.com
#27899: Phrase search query for Postgres full text search
-------------------------------------+-------------------------------------
Reporter: Ilya Semenov | Owner: Andrii
| Soldatenko
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* 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>

Django

unread,
May 27, 2017, 9:26:24 AM5/27/17
to django-...@googlegroups.com
#27899: Phrase search query for Postgres full text search
-------------------------------------+-------------------------------------
Reporter: Ilya Semenov | Owner: Andrii
| Soldatenko
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Andrii Soldatenko):

Sorry for that. Thanks for the link!

--
Ticket URL: <https://code.djangoproject.com/ticket/27899#comment:9>

Django

unread,
Jun 3, 2017, 12:43:01 AM6/3/17
to django-...@googlegroups.com
#27899: Phrase search query for Postgres full text search
-------------------------------------+-------------------------------------
Reporter: Ilya Semenov | Owner: Andrii
| Soldatenko
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by François Freitag):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/27899#comment:10>

Django

unread,
Jun 27, 2018, 3:15:11 PM6/27/18
to django-...@googlegroups.com
#27899: Phrase search query for Postgres full text search
-------------------------------------+-------------------------------------
Reporter: Ilya Semenov | Owner: Andrii
| Soldatenko
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Jun 27, 2018, 3:22:19 PM6/27/18
to django-...@googlegroups.com
#27899: Phrase search query for Postgres full text search
-------------------------------------+-------------------------------------
Reporter: Ilya Semenov | Owner: Andrii
| Soldatenko
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Jun 27, 2018, 4:04:24 PM6/27/18
to django-...@googlegroups.com
#27899: Phrase search query for Postgres full text search
-------------------------------------+-------------------------------------
Reporter: Ilya Semenov | Owner: Greg
| Allensworth

Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Greg Allensworth):

* 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>

Django

unread,
Jun 27, 2018, 4:07:21 PM6/27/18
to django-...@googlegroups.com
#27899: Phrase search query for Postgres full text search
-------------------------------------+-------------------------------------
Reporter: Ilya Semenov | Owner: Greg
| Allensworth
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Jun 27, 2018, 4:09:20 PM6/27/18
to django-...@googlegroups.com
#27899: Phrase search query for Postgres full text search
-------------------------------------+-------------------------------------
Reporter: Ilya Semenov | Owner: Greg
| Allensworth
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Jun 27, 2018, 4:59:43 PM6/27/18
to django-...@googlegroups.com
#27899: Phrase search query for Postgres full text search
-------------------------------------+-------------------------------------
Reporter: Ilya Semenov | Owner: Greg
| Allensworth
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Jun 28, 2018, 2:51:11 AM6/28/18
to django-...@googlegroups.com
#27899: Phrase search query for Postgres full text search
-------------------------------------+-------------------------------------
Reporter: Ilya Semenov | Owner: Greg
| Allensworth
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz):

* 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>

Django

unread,
Jun 28, 2018, 2:51:50 AM6/28/18
to django-...@googlegroups.com
#27899: Phrase search query for Postgres full text search
-------------------------------------+-------------------------------------
Reporter: Ilya Semenov | Owner: Greg
| Allensworth
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz):

* needs_tests: 0 => 1


Comment:

However tests are missing.

--
Ticket URL: <https://code.djangoproject.com/ticket/27899#comment:18>

Django

unread,
Sep 1, 2018, 5:29:27 AM9/1/18
to django-...@googlegroups.com
#27899: Phrase search query for Postgres full text search
-------------------------------------+-------------------------------------
Reporter: Ilya Semenov | Owner: Greg
| Allensworth
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz):

* 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>

Django

unread,
Sep 14, 2018, 3:13:05 PM9/14/18
to django-...@googlegroups.com
#27899: Phrase search query for Postgres full text search
-------------------------------------+-------------------------------------
Reporter: Ilya Semenov | Owner: Greg
| Allensworth
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* 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>

Django

unread,
Sep 15, 2018, 9:24:34 AM9/15/18
to django-...@googlegroups.com
#27899: Phrase search query for Postgres full text search
-------------------------------------+-------------------------------------
Reporter: Ilya Semenov | Owner: Greg
| Allensworth
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/27899#comment:21>

Django

unread,
Sep 17, 2018, 12:04:15 PM9/17/18
to django-...@googlegroups.com
#27899: Phrase search query for Postgres full text search
-------------------------------------+-------------------------------------
Reporter: Ilya Semenov | Owner: Greg
| Allensworth
Type: New feature | Status: closed
Component: contrib.postgres | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* 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>

Reply all
Reply to author
Forward
0 new messages