[Django] #28041: Postgres prefix searching for full text search

22 views
Skip to first unread message

Django

unread,
Apr 6, 2017, 10:34:03 AM4/6/17
to django-...@googlegroups.com
#28041: Postgres prefix searching for full text search
-----------------------------------------+------------------------
Reporter: Joe Tsoi | Owner: nobody
Type: Uncategorized | 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 |
-----------------------------------------+------------------------
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))
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28041>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 6, 2017, 10:36:50 AM4/6/17
to django-...@googlegroups.com
#28041: Postgres prefix searching for full text search
-------------------------------+--------------------------------------
Reporter: Joe Tsoi | Owner: Joe Tsoi
Type: Uncategorized | Status: assigned
Component: Uncategorized | Version: 1.10
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Joe Tsoi):

* owner: nobody => Joe Tsoi
* status: new => assigned


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

Django

unread,
Apr 6, 2017, 11:14:43 AM4/6/17
to django-...@googlegroups.com
#28041: Postgres prefix searching for full text search
----------------------------------+--------------------------------------

Reporter: Joe Tsoi | Owner: Joe Tsoi
Type: New feature | Status: assigned
Component: contrib.postgres | Version: 1.10
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Changes (by Joe Tsoi):

* type: Uncategorized => New feature
* component: Uncategorized => contrib.postgres


--
Ticket URL: <https://code.djangoproject.com/ticket/28041#comment:2>

Django

unread,
Apr 6, 2017, 11:54:39 AM4/6/17
to django-...@googlegroups.com
#28041: Postgres prefix searching for full text search
----------------------------------+------------------------------------

Reporter: Joe Tsoi | Owner: Joe Tsoi
Type: New feature | Status: assigned
Component: contrib.postgres | Version: 1.10
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 Tim Graham):

* stage: Unreviewed => Accepted


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

Django

unread,
Apr 7, 2017, 6:04:03 AM4/7/17
to django-...@googlegroups.com
#28041: Postgres prefix searching for full text search
----------------------------------+------------------------------------
Reporter: Joe Tsoi | Owner: Joe Tsoi
Type: New feature | Status: assigned
Component: contrib.postgres | Version: 1.10
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 Joe Tsoi):

* has_patch: 0 => 1


Comment:

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

--
Ticket URL: <https://code.djangoproject.com/ticket/28041#comment:4>

Django

unread,
Apr 12, 2017, 12:06:36 PM4/12/17
to django-...@googlegroups.com
#28041: Postgres prefix searching for full text search
----------------------------------+------------------------------------
Reporter: Joe Tsoi | Owner: Joe Tsoi
Type: New feature | Status: assigned
Component: contrib.postgres | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 0

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

* needs_docs: 0 => 1
* needs_tests: 0 => 1


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

Django

unread,
Oct 28, 2020, 11:26:50 AM10/28/20
to django-...@googlegroups.com
#28041: Postgres prefix searching for full text search
----------------------------------+---------------------------------------
Reporter: Joe Tsoi | Owner: Karl Hobley

Type: New feature | Status: assigned
Component: contrib.postgres | Version: 1.10
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 Jacob Walls):

* owner: Joe Tsoi => Karl Hobley
* needs_docs: 1 => 0
* needs_tests: 1 => 0


Comment:

[https://github.com/django/django/pull/12727 New PR]

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

Django

unread,
Nov 21, 2020, 3:26:14 AM11/21/20
to django-...@googlegroups.com
#28041: Postgres prefix searching for full text search
----------------------------------+---------------------------------------
Reporter: Joe Tsoi | Owner: Karl Hobley
Type: New feature | Status: assigned
Component: contrib.postgres | Version: 1.10
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 Mariusz Felisiak):

* needs_better_patch: 0 => 1


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

Django

unread,
Jul 22, 2022, 5:48:01 AM7/22/22
to django-...@googlegroups.com
#28041: Postgres prefix searching for full text search
----------------------------------+------------------------------------
Reporter: Joe Tsoi | Owner: (none)
Type: New feature | Status: new

Component: contrib.postgres | Version: 1.10
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 Mariusz Felisiak):

* owner: Karl Hobley => (none)
* status: assigned => new


--
Ticket URL: <https://code.djangoproject.com/ticket/28041#comment:8>

Django

unread,
Nov 14, 2024, 6:13:50 PM11/14/24
to django-...@googlegroups.com
#28041: Postgres prefix searching for full text search
----------------------------------+------------------------------------
Reporter: Joe Tsoi | Owner: (none)
Type: New feature | Status: new
Component: contrib.postgres | Version: 1.10
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 Calvin Vu):

* cc: Calvin Vu (added)

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

Django

unread,
Nov 15, 2024, 4:40:43 PM11/15/24
to django-...@googlegroups.com
#28041: Postgres prefix searching for full text search
----------------------------------+-------------------------------------
Reporter: Joe Tsoi | Owner: Calvin Vu
Type: New feature | Status: assigned
Component: contrib.postgres | Version: 1.10
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 Calvin Vu):

* owner: (none) => Calvin Vu
* status: new => assigned

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

Django

unread,
Feb 17, 2025, 11:32:26 AMFeb 17
to django-...@googlegroups.com
#28041: Postgres prefix searching for full text search
----------------------------------+-------------------------------------
Reporter: Joe Tsoi | Owner: Calvin Vu
Type: New feature | Status: assigned
Component: contrib.postgres | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
----------------------------------+-------------------------------------
Changes (by Jacob Walls):

* needs_tests: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/28041#comment:11>

Django

unread,
Feb 17, 2025, 1:16:50 PMFeb 17
to django-...@googlegroups.com
#28041: Postgres prefix searching for full text search
----------------------------------+-------------------------------------
Reporter: Joe Tsoi | Owner: Calvin Vu
Type: New feature | Status: assigned
Component: contrib.postgres | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
----------------------------------+-------------------------------------
Changes (by Jacob Walls):

* needs_docs: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/28041#comment:12>

Django

unread,
Mar 23, 2025, 11:57:54 AMMar 23
to django-...@googlegroups.com
#28041: Postgres prefix searching for full text search
-------------------------------------+-------------------------------------
Reporter: Joe Tsoi | Owner: Calvin Vu
Type: New feature | Status: assigned
Component: contrib.postgres | Version: 1.10
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 Jacob Walls):

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

Comment:

(Heads up there are several co-authors here we should try to preserve when
squashing.)

Additional input would be appreciated on this
[https://github.com/django/django/pull/18823#discussion_r1966953133
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/28041#comment:13>

Django

unread,
Sep 16, 2025, 3:09:22 PM (21 hours ago) Sep 16
to django-...@googlegroups.com
#28041: Postgres prefix searching for full text search
-------------------------------------+-------------------------------------
Reporter: Joe Tsoi | Owner: Calvin Vu
Type: New feature | Status: closed
Component: contrib.postgres | Version: 1.10
Severity: Normal | Resolution: fixed
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 Jacob Walls <jacobtylerwalls@…>):

* resolution: => fixed
* status: assigned => closed

Comment:

In [changeset:"218f69f05eb51da1ea17d62a914a67ceff5bfd55" 218f69f]:
{{{#!CommitTicketReference repository=""
revision="218f69f05eb51da1ea17d62a914a67ceff5bfd55"
Fixed #28041 -- Added Lexeme expression to contrib.postgres.search.

This expression automatically escapes its input and allows
fine-grained control over prefix matching and term weighting
via logical combinations.

Thanks Mariusz Felisiak, Adam Zapletal, Paolo Melchiorre,
Jacob Walls, Adam Johnson, and Simon Charette for reviews.

Co-authored-by: joetsoi <joe...@users.noreply.github.com>
Co-authored-by: Karl Hobley <ka...@kaed.uk>
Co-authored-by: Alexandr Tatarinov <tatari...@gmail.com>
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/28041#comment:14>
Reply all
Reply to author
Forward
0 new messages