public void AddResult(SearchInfo info, Hits hits, int maxMatches)
 {
     if ( docs == null)
         docs = new Dictionary<SearchInfo, List<ExDocument>>();
     if (hits == null)
         return;
     if (info == null)
         return;
     List<ExDocument> exdl = new List<ExDocument>();
     for (int i = 0; i < maxMatches && i < hits.Length(); i++)
     {
         exdl.Add(new ExDocument(hits.Doc(i),hits.Score(i)));
     }
     if ( exdl.Count > 0)
        docs.Add(info, exdl);
 }
Beispiel #2
0
        static void testSearch()
        {
            string path = @"d:\Indexer\config.xml";
            SearchMaker searcher = new SearchMaker(path);
            QueryInfo info = new QueryInfo();
            info.IndexNames = "Recource_LA_PCXXB";
            info.SearchWords = "东丽区2004年第十三批农用地转用";
            //info.FilterList.Add(new FilterCondition("","JSDW", "东丽"));
            //info.ExcludeList.Add(new ExcludeCondition("", "JSDW", "国家"));
            //info.RangeList.Add(new RangeCondition("","KGSJ","20000501","20090702"));
            SearchInfo si=new SearchInfo();
            //si.Query =info;
            //FileStream fs = new FileStream(@"F:\search.xml", FileMode.Open);

            //System.Xml.Serialization.XmlSerializer xsr = new XmlSerializer(typeof(SearchInfo));
            ////xsr.Serialize(fs,si);
            //si = (SearchInfo)xsr.Deserialize(fs);
            //fs.Close();
            //Console.WriteLine(si.ToString());
            DateTime start = DateTime.Now;
            Query query;
            Dictionary<string, int> statis;
            //List<SearchRecord> results = searcher.ExecuteFastSearch(info, out query, true);
            List<SearchRecord> results = searcher.ExecutePageSearch(info, out query, out statis,"",10,1, true);
            //Console.WriteLine(query.ToString());
            //SearchResult sr = new SearchResult();
            //sr.PageNum = 1;
            //sr.TotalPages = 1;
            //sr.Docs.AddRange(results);
            //System.Xml.XmlWriter writer = new System.Xml.XmlTextWriter(@"F:\result.xml", null);
            //FileStream fs = new FileStream(@"F:\result.xml", FileMode.Append);

            //System.Xml.Serialization.XmlSerializer xsr = new XmlSerializer(typeof(SearchResult));
            //xsr.Serialize(fs,sr);
            //fs.Close();
            //FileStream fs = new FileStream(@"F:\result.xml", FileMode.Open);
            
            //System.Xml.Serialization.XmlSerializer xsr = new XmlSerializer(typeof(SearchResult));
            //sr=(SearchResult)xsr.Deserialize(fs);
            //fs.Close();
            //Console.WriteLine(sr.ToString());

            //writer.Close();
            //TimeSpan span = DateTime.Now - start;
            //Console.WriteLine(string.Format("Spend {0} ", span.ToString()));
            ////ISUtils.SupportClass.Result.Output(result);
            int i = 0;
            foreach (SearchRecord doc in results)
            {
                i++;
                System.Xml.Serialization.XmlSerializer xsr = new XmlSerializer(typeof(SearchRecord));
                FileStream writer = new FileStream(@"F:\test.xml", FileMode.Create);

                xsr.Serialize(writer, doc);
                writer.Close();
                foreach (SearchField field in doc.Fields)
                {
                    string key = field.Name;
                    string value = field.Value;
                    Console.WriteLine(key + ":\t" + value);
                }
                Console.WriteLine("--------------------------------");
            }
            Console.WriteLine("count="+results.Count.ToString());
        }