///////////////////////////////////////////////////////// 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); } }