我想返回SearchDocument对象的字段value
。例如,我使用:
class SearchResult(Handler):
def get(self):
index = search.Index("INDEX_NAME")
results = index.search("Brian")
self.render('search-result.html', results = results)
结果对象看起来像这样:
search.SearchResults(results=[
search.ScoredDocument(
doc_id=u'6122080743456768',
fields=[search.TextField(name=u'full_name', value=u"Brian Jones"),
language=u'en',
rank=106509239L),
search.ScoredDocument(
doc_id=u'4714705859903488',
fields=[search.TextField(name=u'full_name', value=u"Brian Lara"),
language=u'en',
rank=106427057L)],
number_found=2L)
在 search-result.html 中,如何返回字段的value
?
...
<body>
{{ field_values }} #return the field values "Brian Lara" and "Brian Jones"
<body>
...
答案 0 :(得分:0)
从这里开始:
{% for result in results %}
{{ result.fields[0].value }}
{% endfor %}
(您的字段中有[&#39;不匹配。修复此问题,然后检查语法)