public async Task <bool> RunIndexMaintenanceAsync() { //optimize on startup TdIndexWriter.Optimize(); TdIndexWriter.Commit(); ShutDownWriter(); return(await Task.FromResult(true)); }
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; })); }
private void UpdateIndexForItem(SearchIndexItem item) { TdIndexWriter.UpdateDocument( new Term("id", item.Id.ToString(CultureInfo.InvariantCulture)), item.ToLuceneDocument()); }