private static void CheckIndexerStatus(SearchIndexerClient indexerClient, SearchIndexer indexer)
        {
            try
            {
                string indexerName           = "hotels-sql-idxr";
                SearchIndexerStatus execInfo = indexerClient.GetIndexerStatus(indexerName);

                Console.WriteLine("Indexer has run {0} times.", execInfo.ExecutionHistory.Count);
                Console.WriteLine("Indexer Status: " + execInfo.Status.ToString());

                IndexerExecutionResult result = execInfo.LastResult;

                Console.WriteLine("Latest run");
                Console.WriteLine("Run Status: {0}", result.Status.ToString());
                Console.WriteLine("Total Documents: {0}, Failed: {1}", result.ItemCount, result.FailedItemCount);

                TimeSpan elapsed = result.EndTime.Value - result.StartTime.Value;
                Console.WriteLine("StartTime: {0:T}, EndTime: {1:T}, Elapsed: {2:t}", result.StartTime.Value, result.EndTime.Value, elapsed);

                string errorMsg = (result.ErrorMessage == null) ? "none" : result.ErrorMessage;
                Console.WriteLine("ErrorMessage: {0}", errorMsg);
                Console.WriteLine(" Document Errors: {0}, Warnings: {1}\n", result.Errors.Count, result.Warnings.Count);
            }
            catch (Exception e)
            {
                // Handle exception
            }
        }
예제 #2
0
        private static async Task <bool> CheckIndexerStatus()
        {
            Console.WriteLine("Waiting for indexing to complete...");
            IndexerExecutionStatus requestStatus = IndexerExecutionStatus.InProgress;

            try
            {
                await _searchIndexerClient.GetIndexerAsync(IndexerName);

                while (requestStatus.Equals(IndexerExecutionStatus.InProgress))
                {
                    Thread.Sleep(3000);
                    SearchIndexerStatus info = await _searchIndexerClient.GetIndexerStatusAsync(IndexerName);

                    requestStatus = info.LastResult.Status;
                    if (DebugMode)
                    {
                        Console.WriteLine("Current indexer status: {0}", requestStatus.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                if (DebugMode)
                {
                    Console.WriteLine("Error retrieving indexer status: {0}", ex.Message);
                }
                return(false);
            }
            return(requestStatus.Equals(IndexerExecutionStatus.Success));
        }
예제 #3
0
 public OptimizerConfig(SearchIndexerStatus @status, DateTime @nextRunAt, int @intervalHours, String @ixid, String @lastException, String @lockName)
 {
     this.statusValue        = @status;
     this.nextRunAtValue     = @nextRunAt;
     this.intervalHoursValue = @intervalHours;
     this.ixidValue          = @ixid;
     this.lastExceptionValue = @lastException;
     this.lockNameValue      = @lockName;
 }
예제 #4
0
 public ReindexerConfig(SearchIndexerStatus @status, DateTime @startedAt, int @progressInPercent, String @ixid, String @lastException, String @objIdRange, String @lockName)
 {
     this.statusValue            = @status;
     this.startedAtValue         = @startedAt;
     this.progressInPercentValue = @progressInPercent;
     this.ixidValue          = @ixid;
     this.lastExceptionValue = @lastException;
     this.objIdRangeValue    = @objIdRange;
     this.lockNameValue      = @lockName;
 }
예제 #5
0
 public UpdaterConfig(SearchIndexerStatus @status, DateTime @nextRunAt, int @intervalMinutes, DateTime @updateNewerThan, int @progressInPercent, String @ixid, String @lastException, String @lockName)
 {
     this.statusValue            = @status;
     this.nextRunAtValue         = @nextRunAt;
     this.intervalMinutesValue   = @intervalMinutes;
     this.updateNewerThanValue   = @updateNewerThan;
     this.progressInPercentValue = @progressInPercent;
     this.ixidValue          = @ixid;
     this.lastExceptionValue = @lastException;
     this.lockNameValue      = @lockName;
 }
        static async Task PollSearchIndexer(AppSettings settings)
        {
            await Task.Delay(TimeSpan.FromSeconds(5));

            SearchIndexerClient indexerClient = new SearchIndexerClient(settings.SearchEndpointUri, settings.SearchKeyCredential);

            while (true)
            {
                SearchIndexerStatus status = await indexerClient.GetIndexerStatusAsync(SEARCH_ACL_INDEXER_NAME);

                if (status.LastResult != null &&
                    status.LastResult.Status != IndexerExecutionStatus.InProgress)
                {
                    Console.WriteLine("Completed indexing sample data");
                    break;
                }

                Console.WriteLine("Indexing has not finished. Waiting 5 seconds and polling again...");
                await Task.Delay(TimeSpan.FromSeconds(5));
            }
        }