lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antony Bowesman <...@teamware.com>
Subject Re: maxDoc and arrays
Date Fri, 25 May 2007 06:33:09 GMT
Carlos Pita wrote:
> Hi all,
> 
> Is there any guaranty that the maxDoc returned by a reader will be about 
> the
> total number of indexed documents?

It struck me in this thread was that there may be a misunderstanding of the 
relationship between numDocs/maxDoc and an IndexReader.

When an IndexReader is opened its maxDoc and numDocs will never change 
regardless of the additions or deletions to the index.  At least I've not been 
able to make them change in my test cases.

So, when adding a new document after a reader has been opened, this new document 
is not yet visible via the original reader, so if you are caching that array, 
you would not update that array as it relates to the reader on the index at the 
time the reader was opened.

When you open a new reader, the numDocs and maxDoc will reflect that addition. 
Same applies to deletions.  After opening the reader, you would need to 
regenerate you array cache.

As Hoss has said, this is pretty much what FieldCache does and it holds the 
caches keyed by the IndexReader.

Antony



---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message