-
-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
Update the README with some instructions on how to use the Headline class and present matched excerpts from the result set....
https://github.com/damoti/django-tsvector-field/blob/master/tsvector_field/query.py#L5
from django.db.models.expressions import F
from django.contrib.postgres.search import SearchRank, SearchQuery
import tsvector_field
query = SearchQuery(self.form['text'].value())
qs = (
qs.filter(text__search=query)
.annotate(
match_title=tsvector_field.Headline(F('text__title'), query),
match_text=tsvector_field.Headline(F('text__text'), query)
)
.annotate(rank=SearchRank(F('text__search'), query))
.order_by('-rank')
)
Metadata
Metadata
Assignees
Labels
No labels