public RenamingLuceneDriver (string index_name, int minor_version) { this.driver = new LuceneDriver (index_name, minor_version); this.name_index = new NameIndex (this.driver.IndexDirectory, this.driver.Fingerprint); this.driver.ChangedEvent += OnLuceneDriverChanged; this.driver.ChildIndexableEvent += OnLuceneChildIndexableEvent; this.driver.UrisFilteredEvent += OnLuceneUrisFilteredEvent; }
public RenamingLuceneDriver(string index_name, int minor_version) { this.driver = new LuceneDriver(index_name, minor_version); this.name_index = new NameIndex(this.driver.IndexDirectory, this.driver.Fingerprint); this.driver.ChangedEvent += OnLuceneDriverChanged; this.driver.ChildIndexableEvent += OnLuceneChildIndexableEvent; this.driver.UrisFilteredEvent += OnLuceneUrisFilteredEvent; }
///////////////////////////////////////////////////////// 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); } }
///////////////////////////////////////////////////////// #if false static void ExecuteList() { LuceneDriver driver = new LuceneDriver(index_dir, true); IndexReader reader = IndexReader.Open(driver.Store); for (int i = 0; i < reader.NumDocs(); i++) { if (reader.IsDeleted(i)) { continue; } Console.WriteLine(reader.Document(i)); } reader.Close(); }
///////////////////////////////////////////////////////// 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); } }
///////////////////////////////////////////////////////// static void ExecuteList() { LuceneDriver driver = new LuceneDriver (index_dir, true); IndexReader reader = IndexReader.Open (driver.Store); for (int i = 0; i < reader.NumDocs (); i++) { if (reader.IsDeleted (i)) continue; Console.WriteLine (reader.Document (i)); } reader.Close (); }