lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Trejkaz <>
Subject Upgrading Lucene 4 index to 5 doesn't update it - for just some indices
Date Mon, 06 Jul 2015 03:35:02 GMT
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 = {
                new lucene3.IndexUpgrader(directory,

        if (currentVersion < 4) {
            try (lucene4.Directory directory = {
                new lucene4.IndexUpgrader(directory,

        if (currentVersion < 5) {
            try (Directory directory = {
                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?


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

View raw message