Re: get the total number of hits of a query

2010-02-23 Thread jm
perfect, thanks guys On Tue, Feb 23, 2010 at 5:28 PM, Uwe Schindler wrote: > Hi, > > TopDocs tp = ms.search(lucquery, Integer.MAX_VALUE); > > ^^^This will crash and throw OutOfMemoryException > > The simpliest way ist: > TopDocs tp = ms.search(lucquery, 1); > And then the total count is in tp.tot

RE: get the total number of hits of a query

2010-02-23 Thread Uwe Schindler
Hi, TopDocs tp = ms.search(lucquery, Integer.MAX_VALUE); ^^^This will crash and throw OutOfMemoryException The simpliest way ist: TopDocs tp = ms.search(lucquery, 1); And then the total count is in tp.totalHits -- simple. The above query will still count all hits, but return only 1. Adjust acco

Re: get the total number of hits of a query

2010-02-23 Thread Cristian Vat
You shouldn't set the number of documents wanted to Integer.MAX_VALUE. The number of documents to the search method gives the size of the hit queue where the results are stored so you would end up consuming a lot of memory. Much easier to set it to something very small. Lucene must traverse all th