我正在尝试从 Solr 搜索中输出突出显示的搜索词。我正在使用带有 Scorched 的 Django 1.8.4。
我已经激活了突出显示(resp = ('highlighting', self.solr_response.highlighting))
和搜索视图,我从搜索中得到的 json 输出是:
"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..."
]
},
)
问题是我找不到告诉 Django 模板系统访问它的方法some_field
,因为它在下面content.highlighting
(并且它的 id 在下面result.id
)。当然content.highlighting.result.id.some_field
不起作用 - 有没有办法连接类似的东西{{ content.highlighting}} + {{ result.id }}
,以便我可以在模板中输出突出显示的字符串?