GroupDocs index migration fails (destroys index)

Hello again,

I’m honest: I’m a bit frustrated by the amount of bugs we are experiencing with GroupDocs.Search. :confused:

I just wanted to verify OverflowException: Arithmetic operation resulted in an overflow - #13 by jamsharp (have not been able to do so yet).

I read that the index structure got a breaking change, so I followed the steps here to test the migration for a random 6 GB index on my PC: Update index | GroupDocs

Result: Executing the code destroys the index. After executing it, its size shrinks from 6GB to 2MB and according to the GroupDocs classes, there are then 0 documents in it. It does not matter whether original index path and migrated index path are identical or not. No exception or anything. It takes 25 seconds and then, the index is gone.

This was our test code by the way:

static int MigrateIndex(string sourceIndexFolder, string targetIndexFolder)
{
    if (!Directory.Exists(sourceIndexFolder))
    {
        Console.WriteLine($"Source index folder '{sourceIndexFolder}' does not exist.");
        return 1;
    }

    Console.WriteLine("Initializing license...");

    new License().SetLicense("license.lic");

    Console.WriteLine("Initialized license...");

    var updater = new IndexUpdater();

    // Logging number of documents before migration does not work, because version does not match.

    if (!updater.CanUpdateVersion(sourceIndexFolder))
    {
        Console.WriteLine(updater.IsLatestVersion(sourceIndexFolder)
            ? "The source index is already at the latest version. No migration necessary."
            : "The source index version is not supported for migration.");
        return 0;
    }

    Console.WriteLine($"Migrating index from '{sourceIndexFolder}' to '{targetIndexFolder}'...");

    var stopwatch = Stopwatch.StartNew();
    var result = updater.UpdateVersion(sourceIndexFolder, targetIndexFolder);
    stopwatch.Stop();

    Console.WriteLine($"Migration took {stopwatch.Elapsed}.");
    LogDocumentCount("Target index (after migration)", targetIndexFolder);

    Console.WriteLine(result switch
    {
        VersionUpdateResult.Updated => "Index migrated successfully.",
        VersionUpdateResult.AlreadyUpToDate => "The source index was already at the latest version.",
        VersionUpdateResult.Unsupported => "The source index version is not supported for migration.",
        _ => $"Unknown migration result: {result}",
    });

    return result == VersionUpdateResult.Unsupported ? 1 : 0;
}

static void LogDocumentCount(string description, string indexFolder)
{
    try
    {
        using var index = new GroupDocs.Search.Index(indexFolder);
        Console.WriteLine($"{description}: {index.GetIndexedDocuments().Length} document(s).");
    }
    catch (Exception exception)
    {
        Console.WriteLine($"{description}: could not determine document count ({exception.Message}).");
    }
}

HI @jamsharp !

We are sorry to hear that this version did not make proper idnex update.
I hope this was test environment and you have backed up this index .

However it seems like this failed index was built without current access to all added documents that lead new index process to skip the indexed document with no access to them.
So new index became small.

We revised and over viewed current building implementation process and will release shortly next version 27.1 that will allow to update previous version index with new one even without document access.
The hot fix will be delivered within 1-2 days ASAP.
Thank you for cooperation!