Ejemplo n.º 1
0
        public async Task RefreshSearchIndex(IDocumentationIndex documentationIndex)
        {
            if (!_Options.Search?.Enabled ?? false)
            {
                return;
            }

            var documentationDirectoryInfo = _Options.GetDocumentationFolderAsAbsolute(_HostingEnvironment.ContentRootPath);

            SearchIndex = new BasicSearchIndex(_SearchPipeline, documentationIndex, _Options, _Logger);
            await SearchIndex.BuildIndex();

            var json = JsonSerializer.Serialize((BasicSearchIndex)SearchIndex, new JsonSerializerOptions
            {
                IgnoreNullValues = true
            });
            var searchDocumentPath = Path.Combine(documentationDirectoryInfo.FullName, "search.json");
            await File.WriteAllTextAsync(searchDocumentPath, json);

            documentationIndex.DefaultProject.Documents.Add(new GenericDocumentationDocument
            {
                Path       = searchDocumentPath,
                LastUpdate = DateTime.Now
            });
        }
Ejemplo n.º 2
0
        public async Task RefreshSearchIndex(IDocumentationIndex documentationIndex)
        {
            if (!_Options.Search?.Enabled ?? false)
            {
                return;
            }

            _Logger.LogInformation("Building search index.");

            var documentationDirectoryInfo = _Options.GetDocumentationFolderAsAbsolute(_HostingEnvironment.ContentRootPath);

            SearchIndex = new BasicSearchIndex(_SearchPipeline, documentationIndex, _Options, _Logger);
            await SearchIndex.BuildIndex();

            var json = JsonSerializer.Serialize((BasicSearchIndex)SearchIndex, new JsonSerializerOptions
            {
                IgnoreNullValues = true
            });
            var searchDocumentPath = Path.Combine(documentationDirectoryInfo.FullName, "search.json");

            _Logger.LogInformation($"Saving {searchDocumentPath}");

            await File.WriteAllTextAsync(searchDocumentPath, json);
        }
Ejemplo n.º 3
0
 public async Task RefreshSearchIndex(IDocumentationIndex documentationIndex)
 {
     SearchIndex = new LuceneSearchIndex(documentationIndex);
     await SearchIndex.BuildIndex();
 }