File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -235,6 +235,23 @@ a highlighted version of the result::
235
235
result = sqs[0]
236
236
result.highlighted['text'][0] # u'Two computer scientists walk into a bar. The bartender says "<em>Foo</em>!".'
237
237
238
+ The default functionality of the highlighter may not suite your needs.
239
+ You can pass additional keyword arguments to ``highlight `` that will
240
+ ultimately be used to build the query for your backend. Depending on the
241
+ available arguments for your backend, you may need to pass in a dictionary
242
+ instead of normal keyword arguments::
243
+
244
+ # Solr defines the fields to higlight by the ``hl.fl`` param. If not specified, we
245
+ # would only get `text` back in the ``highlighted`` dict.
246
+ kwargs = {
247
+ 'hl.fl': 'other_field',
248
+ 'hl.simple.pre': '<span class="highlighted">',
249
+ 'hl.simple.post': '</span>'
250
+ }
251
+ sqs = SearchQuerySet().filter(content='foo').highlight(**kwargs)
252
+ result = sqs[0]
253
+ result.highlighted['other_field'][0] # u'Two computer scientists walk into a bar. The bartender says "<span class="highlighted">Foo</span>!".'
254
+
238
255
``models ``
239
256
~~~~~~~~~~
240
257
You can’t perform that action at this time.
0 commit comments