Exemplo n.º 1
0
        public SearchMaker(string filename)
        {
            try
            {
                Config parser = new Config(filename,true);
                searchd = parser.GetSearchd();
                sourceList = parser.GetSourceList();
                indexList = parser.GetIndexList();
                dictSet = parser.GetDictionarySet();
                fileSet = parser.FileIndexSet;
            }
            catch (Exception ex)
            {
#if DEBUG
                Console.WriteLine(string.Format("Exception for open file {0},{1}", filename, ex.ToString()));
#endif
                throw;
            }
        }
Exemplo n.º 2
0
        public IndexMaker(string filename)
        {
            try
            {
                Config parser = new Config(filename,true);
                sourceList = parser.GetSourceList();
                indexList = parser.GetIndexList();
                indexer = parser.GetIndexer();
                dictSet = parser.GetDictionarySet();
                fileSet = parser.FileIndexSet;
            }
            catch (Exception ex)
            {
#if DEBUG
                Console.WriteLine(string.Format("IndexMaker,发生异常,文件名:\t{0},\t异常:\t{1}", filename, ex.ToString()));
#endif
                throw;
            }
            Init();
        }
Exemplo n.º 3
0
        private bool InitData(string filename)
        {
            try
            {
                Config parser = new Config(filename,true);
                searchSet = parser.GetSearchd();
                sourceList = parser.GetSourceList();
                indexList = parser.GetIndexList();
                dictSet = parser.GetDictionarySet();
                indexerSet = parser.GetIndexer();
                fileSet = parser.FileIndexSet;
                return true;
            }
            catch (Exception ex)
            {
#if DEBUG
                Console.WriteLine(string.Format("Exception for open file {0},{1}", filename, ex.ToString()));
#endif
                ShowError(string.Format("Exception for open file {0},{1}", filename, ex.ToString()));
                return false;
            }
        }
Exemplo n.º 4
0
 static void TestChineseSearch()
 {
     string path = @"d:\Indexer\config.conf";
     try
     {
         List<Source> sourceList;
         List<IndexSet> indexList;
         DictionarySet dictSet;
         SearchSet searchd;
         Config parser = new Config(path,false);
         searchd = parser.GetSearchd();
         sourceList = parser.GetSourceList();
         indexList = parser.GetIndexList();
         dictSet = parser.GetDictionarySet();
         QueryInfo info = new QueryInfo();
         info.IndexNames = "in_main1,in_main2";
         info.SearchWords = "中国人民解放军 93688";
         Console.WriteLine("SetSearchSettings");
         ISUtils.Utils.SearchUtil.SetSearchSettings(sourceList, indexList, dictSet, searchd);
         Console.WriteLine("SetQueryInfo");
         ISUtils.Utils.SearchUtil.SetQueryInfo(info);
         Console.WriteLine("UseDefaultChineseAnalyzer");
         //ISUtils.Utils.SearchUtil.UseDefaultChineseAnalyzer(true);
         //List<QueryResult.SearchInfo> qrsiList;
         Console.WriteLine("Search");
         //IndexSearcher searcher = new IndexSearcher(@"E:\TEMP\in_MAIN1\");
         ////TDZL,QSXZ,SYQLX,SYQR,LZDDH
         //QueryParser queryParser = new QueryParser("LZDDH", new ChineseAnalyzer());
         //Query query = queryParser.Parse("中国人民解放军 93688");
         ////输出我们要查看的表达式
         //Console.WriteLine(query.ToString());
         DateTime start = DateTime.Now;
         //Hits hits = searcher.Search(query);
         Hits hits = ISUtils.Utils.SearchUtil.Search();
         TimeSpan tm = DateTime.Now - start;
         for (int i = 0; i < hits.Length(); i++)
         {
             Document doc = hits.Doc(i);
             Console.WriteLine(doc.ToString());
             //Console.WriteLine(string.Format("title:{0} \nhistoryName:{1}", doc.Get("id"), doc.Get("historyName")));
         }
         Console.WriteLine(hits.Length());
         Console.WriteLine("搜索测试完成,花费时间:" + tm.TotalMilliseconds.ToString() + "毫秒");
         //List<Hits> hitsList = ISUtils.Utils.SearchUtil.Search(out qrsiList);
         //QueryResult result = new QueryResult();
         //Console.WriteLine("AddResult");
         //result.AddResult(qrsiList, hitsList, searchd.MaxMatches);
         //Console.WriteLine("Output");
         //foreach (QueryResult.SearchInfo si in result.docs.Keys)
         //{
         //    Console.WriteLine("index :" + si.IndexName);
         //    foreach (QueryResult.ExDocument ed in result.docs[si])
         //    {
         //        Console.Write("Score=" + ed.score.ToString());
         //        foreach (string s in si.Fields)
         //        {
         //            Console.Write("\t" + ed.doc.Get(s));
         //        }
         //        Console.WriteLine();
         //        //Response.Write(ISUtils.SupportClass.Document.ToString(ed.doc)+ "<br>");
         //        //Console.WriteLine(string.Format("title:{0} \nhistoryName:{1}", doc.Get("id"), doc.Get("historyName")));
         //    }
         //}
         Console.WriteLine("Finish!");
     }
     catch (Exception e)
     {
         Console.WriteLine(e.StackTrace.ToString());
     }
 }