lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adrien Grand <jpou...@gmail.com>
Subject Re: Distinction between AtomicReader and CompositeReader
Date Wed, 24 Apr 2013 23:14:26 GMT
Hi Paul

On Wed, Apr 24, 2013 at 1:35 PM, Paul Taylor <paul_t100@fastmail.fm> wrote:
> Trying to convert some Lucene 3 code to Lucene 4,
>
> I want to use termEnums.docs(ir.getLiveDocs()) to only return docs that have
> not been deleted for a particular term. However getLiveDocs() is only
> available for AtomicReaders, and although I just have a single index it is
> file based and uses DirectoryReader (which is a subclass of
> CompositeReader).
>
> So I guess I could use SlowCompositeReaderWrapper but the name deters me
> from this, but what I dont understand is that isnt almost everyone using
> indexes based on the filesystem, isnt almost everyone using CompositeReaders
> ?
>
> Yet the documentation seems to be implying we should be using AtomicReaders
> but I dont understand how I could possibly do this with a file based index,
> maybe if the file based index only had a single segment, but aren't segments
> created by Lucene as it requires them and not usually closely controlled by
> the end user application.

Lucene storage is based on segments and Lucene 3.x used to expose
information from these segments in a consolidated manner. Although
elegant, this tends to be slow, this is why Lucene 4.x was modified to
execute everything on a per-segment basis instead. The
"SlowCompositeReaderWrapper" name tries to discourage people from
using this slow composite view.

On every IndexReader, there is a leaves() method that allows you to
access to the atomic segment readers that your IndexReader is made of.
If you can manage to solve your problem by using the segment readers,
then you should definitely do it. Otherwise, (for example if you only
need to see every term only once), then you should use one of the
static methods on the MultiFields class (that
SlowCompositeReaderWrapper uses under the hood).

-- 
Adrien

---------------------------------------------------------------------
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