Solr highlighting through Scorched in Django

26 views
Skip to first unread message

Luca Guariento

unread,
Oct 5, 2015, 6:54:29 AM10/5/15
to django...@googlegroups.com
Hi all,

I am trying to output the highlighted search-term from a Solr search. I'm using Django 1.8.4 with Scorched.

I have already activated highlighting (resp = ('highlighting', self.solr_response.highlighting)) to the search-view, and my json output from a search is:

"highlighting": {

"f0109b89-4882-44cc-90b2-6a51561d14ee": { }, <!-- nothing here, though the result comes up
"73bc1fe4-2c4a-4036-9373-242811e3e7d9": { },<!-- nothing here, though the result comes up
"b7e7a44a-57c4-4378-94fc-273229b0ac7f":
{
"some_field":
[
"Bla bla bla, <em>highlighted search-term</em> bla bla bla..." <!-- highlighted search term
]
},
)

The problem is that I cannot find the way how to tell the Django template system to access that some_field, since it's under content.highlighting (and its id is under result.id). Of course content.highlighting.result.id.some_field doesn't work - is there a way of concatenating something like {{ content.highlighting}} + {{ result.id }}, so that I can output the highlighted string in the template together with the other corresponding result's fields?

Thanks,
Luca

Vadim Serdiuk

unread,
Oct 5, 2015, 9:18:07 AM10/5/15
to Django users, l.guar...@research.gla.ac.uk
Write template tag. 

понедельник, 5 октября 2015 г., 13:54:29 UTC+3 пользователь Luca Guariento написал:
Reply all
Reply to author
Forward
0 new messages