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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/052.6e833cdf73d60bfc3cc193bd24c9d528%40djangoproject.com.

Reply via email to