我有一个solr文档,看起来像这样:
<response>
<result>
...
</result>
<lst name="highlighting">
<lst name="vda.a">
<arr name="illusDesc">
<str>
Four (possibly five) female <em>figures</em> huddle together in contracted postures. The two largest
</str>
</arr>
</lst>
<lst name="vda.b">
<arr name="illusDesc">
<str>
blah blah <em>figures</em> blha blah blha
</str>
</arr>
</lst>
</lst>
</response>如何遍历突出显示元素?
我在一个html文件中有这个:
{% for result in results %}
<ul>
<li>Id: <a href="#">{{ result.id }}</a></li>
<li>Illustration Description: {{ result.highlighting }}</li>
</ul>
{% endfor %}当然,它会在高亮显示下打印所有文本。我想遍历它以打印每个返回对象的illusDesc文本。“Results”是一个pySolr结果对象。
谢谢。
发布于 2014-05-08 17:40:01
results.docs包含您正在迭代的Solr文档。results.highlighting包含Solr高亮显示。您可以通过将文档的ID用作results.highlighting中的键来访问文档的高亮显示。例如:
results.highlighting[result['id']]['content']https://stackoverflow.com/questions/22927021
复制相似问题