public ActionResult Post(ContentReference reference) { var content = _contentLoader.Get <IContent>(reference); _contentIndexer.Index(content); var rest = Rest(new { path = GetIndexContentPath(content) }); return(rest); }
public override string Execute() { var stopWatch = Stopwatch.StartNew(); var jobStartTime = DateTimeOffset.UtcNow; OnStatusChanged("Ensuring valid index definition"); var(updateOrRecreateResult, recreationReason) = _indexDefinitionHandler.UpdateOrRecreateIndex().GetAwaiter().GetResult(); var message = $"UpdateOrRecreateIndexResult: {updateOrRecreateResult}{NewLine}"; if (updateOrRecreateResult == UpdateOrRecreateResult.Recreated) { message += $"Recreation reason: {recreationReason}{NewLine}"; } var indexContentRequest = new IndexContentRequest { CancellationToken = _cancellationToken, OnStatusChanged = OnStatusChanged, IgnoreContent = new HashSet <ContentReference> { ContentReference.WasteBasket }, VisitedContent = new HashSet <ContentReference>(), Statistics = new IndexStatistics(), }; OnStatusChanged("Indexing content start..."); _contentIndexer.Index(ContentReference.RootPage, indexContentRequest).GetAwaiter().GetResult(); var exceptionsThresholdReached = indexContentRequest.Statistics.Exceptions.Count >= indexContentRequest.ExceptionThreshold; if (exceptionsThresholdReached) { message += "Exceptions threshold reached. " + $"Exceptions: {string.Join(NewLine + NewLine, indexContentRequest.Statistics.Exceptions)}{NewLine}{NewLine}" + $"Failed for content references: {string.Join(",", indexContentRequest.Statistics.FailedContentReferences)}"; throw new ScheduledJobFailedException(message); } if (!_cancellationToken.IsCancellationRequested) { OnStatusChanged("Clearing outdated items..."); _indexGarbageCollector.RemoveOutdatedContent(jobStartTime, indexContentRequest.Statistics.FailedContentReferences).GetAwaiter().GetResult(); } stopWatch.Stop(); message += $"Content has been indexed. Visited content count: {indexContentRequest.VisitedContent.Count}, Time taken: {stopWatch.Elapsed}"; return(message); }
public virtual IEnumerable <ContentIndexingResult> Index(ContentReference contentLink) { var content = ContentLoader.Get <IContent>(contentLink); return(ContentIndexer.Index(content)); }