Skip to content

Commit bbcd038

Browse files
authored
Merge pull request django-haystack#1628 from higs4281/master
Add Elasticsearch example for adjusting highlight tags.
2 parents 2831d08 + 3e5b37d commit bbcd038

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

docs/searchqueryset_api.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,14 @@ instead of normal keyword arguments::
252252
result = sqs[0]
253253
result.highlighted['other_field'][0] # u'Two computer scientists walk into a bar. The bartender says "<span class="highlighted">Foo</span>!".'
254254

255+
Elasticsearch accepts keyword arguments::
256+
257+
# Use the ``pre_tag`` and ``post_tag`` keywords and pass the desired tags as lists.
258+
sqs = SearchQuerySet().filter(content='foo').highlight(
259+
pre_tags=['<strong>'], post_tags=['</strong>'])
260+
result_example = " ".join(sqs[0].highlighted)
261+
# u'Two <strong>foo</strong> computer scientists walk into a bar. The bartender says "<strong>Foo</strong>!"'
262+
255263
``models``
256264
~~~~~~~~~~
257265

0 commit comments

Comments
 (0)