示例#1
0
文件: Search.cs 项目: goto10hq/Shushu
        public void Init()
        {
            var appSettings = new ConfigurationBuilder()
                              .SetBasePath(Directory.GetCurrentDirectory())
                              .AddJsonFile("AppSettings.json")
                              .AddUserSecrets("shushu")
                              .AddEnvironmentVariables()
                              .Build();

            _shushu = new Shushu(appSettings["Shushu:Name"], appSettings["Shushu:ServiceApiKey"], appSettings["Shushu:SearchApiKey"], appSettings["Shushu:Index"]);

            var s0 = new Shu("1", "nene", 130);
            var s1 = new Shu("2", "umiko", 150);

            _shushu.IndexDocument(s0);
            _shushu.IndexDocument(s1);

            var shushus = new List <Shu>
            {
                new Shu("3", "aoba", 140),
                new Shu("4", "momiji", 110),
                new Shu("5", "hifumi", 115),
            };

            _shushu.IndexDocuments(shushus);

            Thread.Sleep(3 * 1000);
        }
示例#2
0
文件: Search.cs 项目: goto10hq/Shushu
        public void DeleteDocument()
        {
            var s = new Shu("6", "kotori", 130);

            _shushu.IndexDocument(s);

            Thread.Sleep(3 * 1000);

            var n = _shushu.CountAllDocuments();

            Assert.AreEqual(6, n);

            Thread.Sleep(3 * 1000);
            _shushu.DeleteDocument("6");
            Thread.Sleep(3 * 1000);

            n = _shushu.CountAllDocuments();
            _shushu.DeleteDocument("5");
        }