Opened 2 years ago

Closed 23 months ago

#31147 closed New feature (fixed)

Add support for ts_headline

Reported by: Hannes Ljungberg Owned by: Hannes Ljungberg
Component: contrib.postgres Version: dev
Severity: Normal Keywords: postgres search ts_headline
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


It would be nice to get support for the Postgres full text search function ts_headline. See

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:

>>> from 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:

Change History (7)

comment:1 Changed 2 years ago by Hannes Ljungberg

Owner: set to Hannes Ljungberg
Status: newassigned

comment:2 Changed 2 years ago by Simon Charette

Triage Stage: UnreviewedAccepted

comment:3 Changed 2 years ago by Hannes Ljungberg

Has patch: set

comment:4 Changed 2 years ago by Mariusz Felisiak

Patch needs improvement: set

comment:5 Changed 2 years ago by Hannes Ljungberg

Patch needs improvement: unset

comment:6 Changed 23 months ago by Mariusz Felisiak

Triage Stage: AcceptedReady for checkin

comment:7 Changed 23 months ago by Mariusz Felisiak <felisiak.mariusz@…>

Resolution: fixed
Status: assignedclosed

In 65ab4f9f:

Fixed #31147 -- Added SearchHeadline to django.contrib.postgres.

Note: See TracTickets for help on using tickets.
Back to Top