[Django] #31147: Add support for ts_headline

14 views
Skip to first unread message

Django

unread,
Jan 8, 2020, 5:25:35 PM1/8/20
to django-...@googlegroups.com
#31147: Add support for ts_headline
-------------------------------------+-------------------------------------
Reporter: Hannes | Owner: (none)
Ljungberg |
Type: New | Status: new
feature |
Component: | Version: master
contrib.postgres | Keywords: postgres search
Severity: Normal | ts_headline
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
It would be nice to get support for the Postgres full text search function
`ts_headline`. See https://www.postgresql.org/docs/current/textsearch-
controls.html#TEXTSEARCH-HEADLINE

`SearchHeadline` would also accept an optional `options` argument which
is a where configuration options like `StartSel` and `StopSel` can be
specified.

My proposed implementation work look like this:

{{{#!python
>>> from django.contrib.postgres.search import SearchHeadline, SearchQuery
>>> query = SearchQuery('brave sir robin')
>>> first_line = Line.objects.annotate(
... headline=SearchHeadline('dialogue', query, options={
... 'StartSel': '<b>',
... 'StopSel': '</b>'
... })
... ).first()
>>> print(first_line.headline)
'<b>Robin</b>. He was not at all afraid to be killed in nasty ways.
<b>Brave</b>, <b>brave</b>, <b>brave</b>, <b>brave</b> <b>Sir</b>
<b>Robin</b>'
}}}

I have this implementation ready if this would be accepted:
https://github.com/django/django/compare/master...hannseman:ts_headline?expand=1

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

Django

unread,
Jan 8, 2020, 5:26:05 PM1/8/20
to django-...@googlegroups.com
#31147: Add support for ts_headline
-------------------------------------+-------------------------------------
Reporter: Hannes Ljungberg | Owner: Hannes
| Ljungberg
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: postgres search | Triage Stage:
ts_headline | Unreviewed
Has patch: 0 | Needs documentation: 0

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

* owner: (none) => Hannes Ljungberg
* status: new => assigned


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

Django

unread,
Jan 8, 2020, 7:41:52 PM1/8/20
to django-...@googlegroups.com
#31147: Add support for ts_headline
-------------------------------------+-------------------------------------
Reporter: Hannes Ljungberg | Owner: Hannes
| Ljungberg
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: postgres search | Triage Stage: Accepted
ts_headline |
Has patch: 0 | Needs documentation: 0

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

* stage: Unreviewed => Accepted


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

Django

unread,
Jan 9, 2020, 4:19:47 AM1/9/20
to django-...@googlegroups.com
#31147: Add support for ts_headline
-------------------------------------+-------------------------------------
Reporter: Hannes Ljungberg | Owner: Hannes
| Ljungberg
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: postgres search | Triage Stage: Accepted
ts_headline |
Has patch: 1 | Needs documentation: 0

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

* has_patch: 0 => 1


Comment:

PR: https://github.com/django/django/pull/12297

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

Django

unread,
Jan 10, 2020, 7:20:37 AM1/10/20
to django-...@googlegroups.com
#31147: Add support for ts_headline
-------------------------------------+-------------------------------------
Reporter: Hannes Ljungberg | Owner: Hannes
| Ljungberg
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: postgres search | Triage Stage: Accepted
ts_headline |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

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

* needs_better_patch: 0 => 1


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

Django

unread,
Feb 7, 2020, 4:03:18 PM2/7/20
to django-...@googlegroups.com
#31147: Add support for ts_headline
-------------------------------------+-------------------------------------
Reporter: Hannes Ljungberg | Owner: Hannes
| Ljungberg
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: postgres search | Triage Stage: Accepted
ts_headline |
Has patch: 1 | Needs documentation: 0

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

* needs_better_patch: 1 => 0


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

Django

unread,
Mar 3, 2020, 7:44:36 AM3/3/20
to django-...@googlegroups.com
#31147: Add support for ts_headline
-------------------------------------+-------------------------------------
Reporter: Hannes Ljungberg | Owner: Hannes
| Ljungberg
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: postgres search | Triage Stage: Ready for
ts_headline | checkin
Has patch: 1 | Needs documentation: 0

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

* stage: Accepted => Ready for checkin


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

Reply all
Reply to author
Forward
0 new messages