Example #1
0
 public async Task<ActionResult> RefreshSearchIndex()
 {
     var azureIndexer = new BlogPostSearchIndex(Config.AzureSearchService, Config.AzureSearchApiKey);
     using (var blogPostRepo = new BlogPostRepo())
     {
         var blogPostsToIndex = blogPostRepo.PublishedPosts.Select(x => new IndexBlogPost { BlogPostBody = x.Body, Id = x.UrlSlug }).ToArray();
         await azureIndexer.AddToIndex(blogPostsToIndex);
     }
     return RedirectToRoute("Front");
 }
Example #2
0
 public async Task SyncAzureIndex(IEnumerable<BlogPost> newOrUpdates, IEnumerable<string> deletedPostSlugs)
 {
     var azureIndexer = new BlogPostSearchIndex(Config.AzureSearchService, Config.AzureSearchApiKey);
     await azureIndexer.AddToIndex(newOrUpdates.Select(x => new IndexBlogPost { Id = x.UrlSlug, BlogPostBody = x.Body }).ToArray());
     await azureIndexer.RemoveFromIndex(deletedPostSlugs.ToArray());
 }