Show all hits in results () object Whoosh

I'm new to python and whoosh, so maybe this makes it difficult for me to print all the images returned after searching .

Here's my code:

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'

      

Here's the output:

<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

      

+3


source to share


3 answers


To print all the results, you should simply iterate over the object results

:



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

      

+1


source


The accepted answer is misleading; it will give you the number of hits limited by the "limit" parameter in the search.

To change this limit use:



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

      

to search with.

+3


source


It looks like you are already on the right track. But in reality there can only be one result.

According to the whoosh docs , calling:

Len (Results)

like you gives you the total number of search hits.

So, if the result displays "1 resultados", that's probably all that is indexed.

0


source







All Articles