Exemple #1
0
 public object IndexStatistics()
 {
     Access.Required(null, null, Function.ReadIndexStatistics);
     using (var search = new Search())
     {
         Dictionary<string, int> result = new Dictionary<string, int>();
         foreach (var type in new IndexInterface().Types)
         {
             result.Add(type, search.IndexStatistics(type));
         }
         return result;
     }
 }
Exemple #2
0
        public object Search()
        {
            lock (typeof(JsonAPI))
            {
                string text = QueryParameters["text"];
                string type = QueryParameters["type"];
                int? skip = OptionalIntParameter("skip");
                int top = int.Parse(QueryParameters["top"]);
                if (!new IndexInterface().Types.Contains(type))
                    throw new ArgumentException("类型无效");

                using (var search = new Search())
                {
                    var searchResult = search.DoSearch(text, type, top);
                    return searchResult;
                }
            }
        }
Exemple #3
0
 static void Main(string[] args)
 {
     Moo.Core.Daemon.FullIndexDaemon.Instance.Start();
     try
     {
         while (true)
         {
             string toSearch = Console.ReadLine();
             DateTime st = DateTime.Now;
             using (var search = new Search())
             {
                 foreach (Search.SearchResult result in search.DoSearch(toSearch, "Problem", 5,0))
                 {
                     Console.WriteLine("ID:{0} Title:", result.ID);
                     foreach (Search.SearchResult.ContentSegment match in result.Title)
                     {
                         Console.Write("-{0}-", match.Text);
                     }
                     Console.WriteLine();
                     foreach (Search.SearchResult.ContentSegment match in result.Content)
                     {
                         Console.Write("-{0}-", match.Text);
                     }
                     Console.WriteLine();
                 }
             }
             Console.WriteLine("{0} -------------------------------------------",DateTime.Now-st);
         }
     }
     catch (Exception)
     {
     }
     Moo.Core.Daemon.FullIndexDaemon.Instance.Stop();
     /*
     string PublicKey = Get("PublicKey");
     RSA rsa=tool.Deserialize<RSA>(PublicKey);
     var rsacsp = new System.Security.Cryptography.RSACryptoServiceProvider();
     rsacsp.ImportParameters(new System.Security.Cryptography.RSAParameters()
     {
         Modulus=Convert.FromBase64String(rsa.Modulus),
         Exponent=Convert.FromBase64String(rsa.Exponent)
     });
     byte[] pwd = rsacsp.Encrypt(Encoding.UTF8.GetBytes("ShaBi"), false);
     Auth = Post("Login", tool.Serialize(new
     {
         userID=2,
         password=Convert.ToBase64String(pwd)
     }));
     Auth = Auth.Substring(1, Auth.Length - 2);
     Console.WriteLine(Auth);
     for (int i = 1000; i < 2000; i++)
     {
         string content = Encoding.Unicode.GetString(File.ReadAllBytes(@"D:\Prob\" + i.ToString()+".txt"));
         content=content.Replace('\'',' ');
         Console.WriteLine(Post("Problems", tool.Serialize(new
         {
             problem = new
                 {
                     Name = i.ToString(),
                     Type = "Traditional",
                     Content = content
                 }
         })));
     }
      * */
 }