Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在results()对象中显示所有点击_Python_Whoosh - Fatal编程技术网

Python 在results()对象中显示所有点击

Python 在results()对象中显示所有点击,python,whoosh,Python,Whoosh,我是python和whoosh方面的新手,所以可能正因为如此,我很难打印搜索后返回的所有点击 这是我的密码: from whoosh.qparser import QueryParser with ix.searcher() as searcher: query = QueryParser("title", ix.schema).parse("hd") results = searcher.search(query) print results[0] print

我是python和whoosh方面的新手,所以可能正因为如此,我很难打印搜索后返回的所有点击

这是我的密码:

from whoosh.qparser import QueryParser
with ix.searcher() as searcher:
    query = QueryParser("title", ix.schema).parse("hd")
    results = searcher.search(query)
    print results[0]
    print results
    print len(results), 'resultados'
以下是输出:

<Hit {'brand': u'Best Buy', 'title': u'best buy easy snap hd', 'superpadre': u'audio foto video', 'familia': u'videocamaras', 'detalle_short': u'Easy Snap HD es una pequena videocamara con grabacion en alta definicion ideada para poder llevarla a cualquier lugar. Su ligero peso y su visor TFT LCD de 2,7  con'}>
<Top 10 Results for Term('title', u'hd') runtime=0.000622987747192>
18 resultados

18结果

看起来你已经走上了正确的轨道。但实际上可能只有一个结果

根据该报告,呼吁:

len(结果)

按原样提供搜索匹配的总数


因此,如果结果在这里显示“1个resultados”,那么这可能就是索引的全部内容

要打印所有结果,只需遍历对象
results

for r in results:
        print r
        print "title :", r["title"] # print the title of each result.

公认的答案具有误导性;它将提供搜索中受“限制”参数限制的点击数

要修改该限制,请使用:

results = searcher.search(query, limit=None)

使用搜索。

这是正确的,但当结果超过1时也会发生这种情况。