Opened 5 years ago
Closed 5 years ago
#31147 closed New feature (fixed)
Add support for ts_headline
Description ¶
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:
>>> 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
Change History (7)
comment:1 by , 5 years ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:2 by , 5 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 5 years ago
Has patch: | set |
---|
comment:4 by , 5 years ago
Patch needs improvement: | set |
---|
comment:5 by , 5 years ago
Patch needs improvement: | unset |
---|
comment:6 by , 5 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
PR: https://github.com/django/django/pull/12297