Skip to content

Instantly share code, notes, and snippets.

@rofr
Created March 7, 2014 12:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rofr/9410314 to your computer and use it in GitHub Desktop.
Save rofr/9410314 to your computer and use it in GitHub Desktop.
More code from geekstream.devrexlabs.com
private void RemoveFeedFromSearchIndex(Feed feed)
{
var searchTermsToRemove = new List<string>();
var itemsToRemove = new HashSet<FeedItem>(feed.Items);
foreach (KeyValuePair<string, HashSet<IndexEntry>> kvp in _searchIndex)
{
var searchTerm = kvp.Key;
var entrySet = kvp.Value;
_statistics.TotalKeywords -= entrySet.RemoveWhere(entry => itemsToRemove.Contains(entry.Item));
if (entrySet.Count == 0) searchTermsToRemove.Add(searchTerm);
}
_statistics.UniqueKeywords -= searchTermsToRemove.Count;
foreach (string searchTerm in searchTermsToRemove) _searchIndex.Remove(searchTerm);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment