Ejemplo n.º 1
0
		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;
		}
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
        /////////////////////////////////////////////////////////

        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);
            }
        }
Ejemplo n.º 4
0
        /////////////////////////////////////////////////////////

#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();
        }
Ejemplo n.º 5
0
        /////////////////////////////////////////////////////////
        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);
            }
        }
Ejemplo n.º 6
0
        /////////////////////////////////////////////////////////
        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 ();
        }