lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler" <...@thetaphi.de>
Subject RE: Upgrading Lucene 4 index to 5 doesn't update it - for just some indices
Date Mon, 06 Jul 2015 06:32:44 GMT
Hi,

It could be the reason for this is your classpath:

If you load all Lucene Versions into the same classloader (but with different package names
- I assume you use Maven Shade plugin to do this), Lucene 3 will load perfectly, yes; Lucene
4 will also load perfectly, yes! But when it tries to load Lucene 5, it will fail to load
all shipped codecs. Codecs are not identified by their Java package name, but by the symbolic
name (like "Lucene50") as written into the index. The SPI interface of Lucene will load all
codecs from classpath and save them in a lookup map based on the symbolic name. If the Lucene
4 JAR file are placed before Lucene 5 JARs, the "slots" for codec names are already taken
(because the Lucene 5 loader will see the Lucene 4 codecs first), so loading Lucene 5 variants
of old codecs is a no-op. This may cause those problems, because Lucene 5 ships with "modified"
versions of the old Lucene 4 codecs - but they are not identical.

You can only workaround by loading the Lucene JARs into completely different classloaders
(don't forget to also set context classloader!). In that case you would not even need to change
package names!

Uwe

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de


> -----Original Message-----
> From: Trejkaz [mailto:trejkaz@trypticon.org]
> Sent: Monday, July 06, 2015 5:35 AM
> To: Lucene Users Mailing List
> Subject: Upgrading Lucene 4 index to 5 doesn't update it - for just some
> indices
> 
> Hi all.
> 
> All our existing indices are versions 2 through 3 and we're trying to migrate
> everything up to 5 (and then later graft additional DocValues in, but that's the
> next step.)
> 
> I wrote a tool which basically does this:
> 
>     public void upgrade2to5(Path path, int currentVersion) {
>         if (currentVersion < 3) {
>             try (lucene3.Directory directory = PathFSDirectory3.open(path)) {
>                 new lucene3.IndexUpgrader(directory,
> lucene3.Version.LUCENE_36).upgrade();
>             }
>         }
> 
>         if (currentVersion < 4) {
>             try (lucene4.Directory directory = PathFSDirectory4.open(path)) {
>                 new lucene4.IndexUpgrader(directory,
> lucene4.Version.LUCENE_4_10_4).upgrade();
>             }
>         }
> 
>         if (currentVersion < 5) {
>             try (Directory directory = FSDirectory.open(path)) {
>                 new IndexUpgrader(directory).upgrade();
>             }
>         }
>     }
> 
> (Tech notes: A bit of glue was put in so that we could use Path with earlier
> versions of Lucene, since we're trying to ditch File in our own application too.
> Package prefixes are shortened for readability, but we basically archive the
> entire lucene-core for a given version into an internal package. I want to trim
> them down to reduce the size, but that comes after confirming that it
> works.)
> 
> Anyway, for the oldest indices we still have available in our own test cases,
> this appears to work. Lucene 5 can open the index at the end.
> However, newer indexes which were already version 3 don't seem to
> upgrade properly because Lucene 5 can't open the result.
> 
> I did some investigation and here's what I found so far:
>     * Both the Lucene 4 and Lucene 5 upgrade steps succeed.
>     * After the Lucene 4 upgrade step, the version checker I wrote says it's
> version 4.
>     * After the Lucene 5 upgrade step, the version checker says it's still version
> 4.
>     * After the Lucene 5 upgrade step, we try to open this index in Lucene 5
> and get the exception about it being too old to open.
> 
> What I don't understand:
> 
>     1. Lucene 5 still opens Lucene 4 indexes (yes, we do have the backward-
> codecs, otherwise the migration would have failed). So this index must be
> Lucene *3*. How can that be, if Lucene 4's IndexUpgrader supposedly
> upgraded it to version 4, and even updated the headers in the files to
> indicate this?
> 
>     2. The Lucene 5 IndexUpgrader never complained about it being out of
> date either. If it's really Lucene 3, why would the Lucene 5 IndexUpgrader
> not complain about anything?
> 
> This just seems completely crazy, but I know that someone out there must
> have seen something like this before. What is going on here?
> 
> TX
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org


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