Sunday, October 4, 2015

Solr highlighting through Scorched in Django

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

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/56121F73.1090103%40research.gla.ac.uk.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment