On Tue, Jan 12, 2010 at 11:02 AM, Jokin Cuadrado <[email protected]> wrote:
> > Hi all, > > I'm upgrading my code to work with Lucene.net 2.9: is there anything I > > should be aware of other then the obsolete methods? Any runtime change or > > different default behavior? > > > > If you take a look to the changelog, you will find that some > optimizations are made to the way the index are reloaded, so it's also > recomended to reopen the indexes using the reopen method (this is the > javadoc info, it's also aplicable for lucene.net): > > http://lucene.apache.org/java/2_9_1/api/all/org/apache/lucene/index/IndexReader.html#reopen()<http://lucene.apache.org/java/2_9_1/api/all/org/apache/lucene/index/IndexReader.html#reopen%28%29> > I also read there is a getReader in the IndexWriter, which gets the most uptodate reader: http://lucene.apache.org/java/2_9_1/api/all/org/apache/lucene/index/IndexWriter.html#getReader() Which might even solve the issue of re-opening a reader > > Opening an index is an expensive operation, and reopening one that has > several changes it's also expensive, warming an indexreader, it's the > operation of making some searchs so the internal caches of lucene > objects are filled. So, the usual case is to spawn a new indexreader > (via new indexreader or reopen), made some searchs on it, and then, > asign the new reader to the active one. following the example in the > reopen: > > IndexReader newReader = r.reopen(); > // reader was reopened > // made some searches with newreader here > .... > OldReader = reader; > reader = newReader; > OldReader .close(); > > > On Tue, Jan 12, 2010 at 9:43 AM, Simone Chiaretta > <[email protected]> wrote: > > > Then, among the obsolete methods: > > I was counting the number of docs indexed by using a search with a > certain > > query: now the Query method requires the max number of results to return. > > Is there a way to do an unbound query? > > Or is there another way to count the number of total results? > > well, i don't already use lucene 2.9 and i can be mistaken, but that > is the max number of documents to retrieve, however, the TopDocs > class, has a totalhits field with the total number of results from the > search. OH.. ok... I didn't understand what that was... > By the way, you query for a know term in every document, or > you use the MatchAllDocsQuery? > I'm doing this search just in the dashboard, to see how many documents are actually in the index (but I do a search because I put docs from different blogs in the same index) Simo > > -- > Jokin > -- Simone Chiaretta Microsoft MVP ASP.NET - ASPInsider Blog: http://codeclimber.net.nz RSS: http://feeds2.feedburner.com/codeclimber twitter: @simonech Any sufficiently advanced technology is indistinguishable from magic "Life is short, play hard"
