Example #1
0
    protected void AddIndexbtn_Click(object sender, EventArgs e)
    {
        Lucene.Net.Store.Directory ramdir = new Lucene.Net.Store.RAMDirectory();

        Console.WriteLine("Indexing...");
        DateTime start = DateTime.Now;

        string path4 = Server.MapPath("./") + @"1.4\\";
        if (System.IO.Directory.Exists(path4))//是否存在目录
        {
            Indexer.IntranetIndexer indexer4 = new Indexer.IntranetIndexer(Server.MapPath("index\\1.4\\"));
            indexer4.AddDirectory(new System.IO.DirectoryInfo(path4), "*.*");
            indexer4.Close();
        }
        //IntranetIndexer indexer = new IntranetIndexer(ramdir);//把索引写进内存

        string path5 = Server.MapPath("./") + @"1.5\\";
        if (System.IO.Directory.Exists(path5))
        {
             Indexer.IntranetIndexer indexer5 = new Indexer.IntranetIndexer(Server.MapPath("index\\1.5\\"));
             indexer5.AddDirectory(new System.IO.DirectoryInfo(path5), "*.*");
             indexer5.Close();

        }

        Console.WriteLine("Done. Took " + (DateTime.Now - start));
        Response.Write("<script type='text/javascript'>window.alert(' 创建索引成功,并已经优化!!! ');</script>");
    }
Example #2
0
        static void Main(string[] args)
        {
            try
            {
                log4net.Config.XmlConfigurator.Configure();
                Console.WriteLine("Indexing...");
                DateTime start = DateTime.Now;

                IntranetIndexer indexer;
                // indexer.AddDirectory(new DirectoryInfo(@"\\PUNE-DATA-01\Support Projects"), "*.*");
                //indexer.AddDirectory(new DirectoryInfo(@"\\SAGITEC-1629\Soogle\SDCERS\"), "*.*");
                //  indexer.AddDirectory(new DirectoryInfo(@"C:\\NILASsource\NilasSupport\DEV\slnNeoSpin\NeoSpinBusinessObjects\Leaves"), "*.*");
                // indexer.AddDirectory(new DirectoryInfo(@"\\SAGITEC-1629\Soogle\SDCERS\"), "*.*");

                //indexer.AddDirectory(new DirectoryInfo(@" \\SAGITEC-1629\Soogle"), "*.*");
                Boolean create = true;
                foreach (DirectoryInfo di in new DirectoryInfo(VirtualPath).GetDirectories())
                {

                    indexer = new IntranetIndexer(IndexPath, create);
                    indexer.AddDirectory(di, "*.*");
                    indexer.Close();
                    create = false;
                }
                // indexer.AddDirectory(new DirectoryInfo(VirtualPath), "*.*");

                // indexer.Close();

                GenerateXML.GenerateXMLFile(XMLFilePath);

            }
            catch (Exception m)
            {
                MyException mobj = new MyException(m.Message);
            }
        }