lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler" <>
Subject RE: 5.x to 6.x migration: replacement for Lucene50Codec
Date Thu, 30 Mar 2017 09:58:12 GMT
> >>> I should have mentioned that I for compatibility reasons still need to
> >>> be able to read/write indexes created with the old version, i.e., with
> >>> the 5.0 codec.
> >
> > The old codecs are read-only! As said before, you can only specify the
> codec for IndexWriter. That means new segemnts to already existing indexes
> will automatically use the new codec. Old segments already in your index will
> stay with the old codec, until they are merged away, in which case they are
> implicitly upgraded.
> Just to be clear: If lucene-backwards-codecs.jar 6.1 is on the classpath
> (and gives me access to Lucene50Codec), can I specify the Lucene50Codec
> in the IndexWriter's IndexWriterConfig and thus get Lucene 6.1 to write
> an index compatible with Lucene 5.0?

Does not work as the Lucene50 Codec can only READ indexes, writing is not implemented. The
Lucene50 Codec is just there to READ indexes which still contain 5.x segments. This is done
by Codec.forName() based on the codec written to the index files.

If you pass an instance of the Lucene50 codec to IndexWriter, you will hit an UnsupportedOperationException
at some point.

> > As the Lucene 5 codec is read only, it is impossible to create a new index (or
> modify an existing index) in a way that it will still be readable with Lucene 5.
> As soon as you touch an index with the new codec, it will be mixed codec
> versions and cannot be read with old version. But Lucene 6 will happily
> handle the mixed codec index - it is designed for that use case (default-codec
> indexes will behave the same way). 😊
> That's a cool feature and may work well for my use case. The only thing
> I worry about is how ServiceLoader-based Codec discovery will work in an
> OSGi environment (specially, an Eclipse plug-in).

Lucene requires ServiceLoader for reading indexes, no way around that. The jar files of Lucene
must _all_ reside in the same ClassLoader or alternatively in the ContextClassLoader. If Lucene's
ServiceLoader would not work in your environment, opening a DirectoryReader would fail ASAP
with a not found exception.


> Best wishes,
> Andreas
> --
> Codetrails GmbH
> The knowledge transfer company
> Robert-Bosch-Str. 7, 64293 Darmstadt
> Phone: +49-6151-276-7092
> Mobile: +49-170-811-3791
> Managing Director: Dr. Marcel Bruch
> Handelsregister: Darmstadt HRB 91940

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message