app.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:candidate-selection-tutorial 作者: candidate-selection-tutorial-sigir2017 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号