Example #1
0
 public async Task <bool> RunIndexMaintenanceAsync()
 {
     //optimize on startup
     TdIndexWriter.Optimize();
     TdIndexWriter.Commit();
     ShutDownWriter();
     return(await Task.FromResult(true));
 }
Example #2
0
 public Task <bool> AddItemsToIndexAsync(IEnumerable <SearchIndexItem> items)
 {
     return(Task.Run(() =>
     {
         try
         {
             foreach (var item in items)
             {
                 UpdateIndexForItem(item);
             }
             TdIndexWriter.Commit();
         } // ReSharper disable once EmptyGeneralCatchClause
         catch
         {
             //TODO: log this somewhere
         }
         return true;
     }));
 }
Example #3
0
 private void UpdateIndexForItem(SearchIndexItem item)
 {
     TdIndexWriter.UpdateDocument(
         new Term("id", item.Id.ToString(CultureInfo.InvariantCulture)),
         item.ToLuceneDocument());
 }