Groupdocs Search (index events)

HI.
//index settings AutoDetectEncoding
IndexSettings settings = new IndexSettings();
settings.AutoDetectEncoding = true;

        //index class with async option
        Index index = new Index(indexPath, settings);
        index.Events.OperationFinished += (sender, args) =>
        {
            // Writing operation details to the console
            Console.WriteLine("Operation finished: " + args.OperationType);
            Console.WriteLine("Message: " + args.Message);
            Console.WriteLine("Index folder: " + args.IndexFolder);
            Console.WriteLine("Time: " + args.Time);
        };
       
        IndexingOptions options = new IndexingOptions();
        options.IsAsync = true;
        
        string[] filesList = System.IO.Directory.GetFiles(indexPath, "*.body");
        if (filesList.Length == 0)
        {
            index.Add(storagePath,options);
        }
        else
        {
            UpdateOptions updateOptions = new UpdateOptions();
            index.Update(updateOptions);

            //MergeOptions mergeOptions = new MergeOptions();
            //index.Optimize(mergeOptions);
        }

i had written the above code.when debugger reaches the index.add() and completes,it should go to the following event right?,
index.Events.OperationFinished += (sender, args) =>
{
// Writing operation details to the console
Console.WriteLine("Operation finished: " + args.OperationType);
Console.WriteLine("Message: " + args.Message);
Console.WriteLine("Index folder: " + args.IndexFolder);
Console.WriteLine("Time: " + args.Time);
};

but its not going back to this event.

actually i wish to know the status of the index and update the data in db

1 Like

@bharathiGK

We’re investigating this scenario. Your invesigation ticket ID is SEARCHNET-2357. As there’s any update, you’ll be notified.

@bharathiGK

The event is not raised because the program exits earlier. An asynchronous operation implies that the Add method completes before the actual indexing operation completes. You have to add the following lines at the end of the console application:

Console.WriteLine("All done.");
Console.ReadKey();

Then you have to run the program and after the text “All done”, wait for the indexing operation to complete.