def search(query, offset, count, draw, solr_endpoint):
"""
This function is responsible for hitting the solr endpoint
and returning the results back.
"""
results = solr_endpoint.search(q=query, **{
'start': int(offset),
'rows': int(count)
})
print("Saw {0} result(s) for query {1}.".format(len(results), query))
formatted_hits = []
for hit in results.docs:
formatted_hits.append(
[hit['_news_title'], hit['_news_publisher'], CATEGORY[hit['_news_category'][0]], hit['_news_url']])
response = {'draw': draw,
'recordsFiltered': results.hits,
'data': formatted_hits}
web.header('Content-Type', 'application/json')
return json.dumps(response)
app.py 文件源码
python
阅读 17
收藏 0
点赞 0
评论 0
评论列表
文章目录