Pārlūkot izejas kodu

[search] Flatten highlighting if there is only one chunk

Romain Rigaux 10 gadi atpakaļ
vecāks
revīzija
2fba6b4
1 mainītis faili ar 1 papildinājumiem un 1 dzēšanām
  1. 1 1
      apps/search/src/search/models.py

+ 1 - 1
apps/search/src/search/models.py

@@ -836,7 +836,7 @@ def augment_solr_response(response, collection, query):
             escaped_highlighting = {}
             for field, hls in highlighting.iteritems():
               _hls = [escape(smart_unicode(hl, errors='replace')).replace('&lt;em&gt;', '<em>').replace('&lt;/em&gt;', '</em>') for hl in hls]
-              escaped_highlighting[field] = _hls
+              escaped_highlighting[field] = _hls[0] if len(_hls) == 1 else _hls
 
             doc.update(escaped_highlighting)
     else: