///////////////////////////////////////////////////////// static void ExecuteRemove(string arg) { LuceneDriver driver = new LuceneDriver(index_dir); if (arg.IndexOf("://") != -1) { Uri uri = new Uri(arg); ICollection hits = driver.DoQueryByUri(uri); if (hits == null || hits.Count == 0) { Console.WriteLine("Uri not found in the index: {0}", uri); Environment.Exit(1); } driver.Remove(uri); driver.Flush(); Console.WriteLine("Successfully removed Uri: {0}", uri); } else { IndexSearcher searcher = new IndexSearcher(driver.Store); BooleanQuery query = new BooleanQuery(); Term term = new Term("prop:k:Tag", arg); // Argh TermQuery term_query = new TermQuery(term); query.Add(term_query, false, false); Hits hits = searcher.Search(query); int n_hits = hits.Length(); string uri; for (int i = 0; i < n_hits; ++i) { Document doc = hits.Doc(i); uri = doc.Get("Uri"); if (uri == null) { continue; } driver.Remove(UriFu.UriStringToUri(uri)); } driver.Flush(); Console.WriteLine("Successfully removed {0} items with tag: {1}", n_hits, arg); } }
public void Flush() { // FIXME: We should add some paranoid checking here. // If one flush succeeds and the other fails, our two // indexes will be out of sync! name_index.Flush(); driver.Flush(); // FIXME: If necessary, fire the ChangedEvent to give // notification of any renames. if (renamed_uris.Count > 0) { if (ChangedEvent != null) { ChangedEvent(this, empty_collection, empty_collection, renamed_uris); } renamed_uris.Clear(); } }
///////////////////////////////////////////////////////// static void ExecuteRemove(string arg) { LuceneDriver driver = new LuceneDriver (index_dir); if (arg.IndexOf ("://") != -1) { Uri uri = new Uri (arg); ICollection hits = driver.DoQueryByUri (uri); if (hits == null || hits.Count == 0) { Console.WriteLine ("Uri not found in the index: {0}", uri); Environment.Exit (1); } driver.Remove (uri); driver.Flush (); Console.WriteLine ("Successfully removed Uri: {0}", uri); } else { IndexSearcher searcher = new IndexSearcher (driver.Store); BooleanQuery query = new BooleanQuery (); Term term = new Term ("prop:k:Tag", arg); // Argh TermQuery term_query = new TermQuery (term); query.Add (term_query, false, false); Hits hits = searcher.Search (query); int n_hits = hits.Length (); string uri; for (int i = 0; i < n_hits; ++i) { Document doc = hits.Doc (i); uri = doc.Get ("Uri"); if (uri == null) continue; driver.Remove (UriFu.UriStringToUri (uri)); } driver.Flush (); Console.WriteLine ("Successfully removed {0} items with tag: {1}", n_hits, arg); } }