Ejemplo n.º 1
0
        public void test_with_write_and_delete_document()
        {
            var lueceneSearchProvider = new BaseSearchProvider();

            var spaceOne = new SpaceObject
            {
                Id             = Guid.NewGuid(),
                SpaceName      = "技术空间",
                FileCount      = 1,
                ParentId       = Guid.NewGuid().ToString(),
                SpaceSize      = 1024,
                CreateTime     = DateTime.Now,
                UpdateTime     = DateTime.Now,
                CreateUserId   = "5",
                CreateUserName = "******",
            };


            Stopwatch stopWatcher = new Stopwatch();

            stopWatcher.Start();

            lueceneSearchProvider.IndexDirectory = "write_delete_space";
            lueceneSearchProvider.Add(spaceOne);

            var results = lueceneSearchProvider.Query <SpaceObject>("空间");

            Assert.IsTrue(results.Count >= 1);

            lueceneSearchProvider.Delete(spaceOne);
            results = lueceneSearchProvider.Query <SpaceObject>("空间");
            Assert.AreEqual(results.Count, 0);

            Console.WriteLine(results.Count);
        }
Ejemplo n.º 2
0
        public void test_with_write_and_delete_document()
        {
            var lueceneSearchProvider = new BaseSearchProvider();

            var spaceOne = new SpaceObject
            {
                Id = Guid.NewGuid(),
                SpaceName = "技术空间",
                FileCount = 1,
                ParentId = Guid.NewGuid().ToString(),
                SpaceSize = 1024,
                CreateTime = DateTime.Now,
                UpdateTime = DateTime.Now,
                CreateUserId = "5",
                CreateUserName = "******",
            };

            Stopwatch stopWatcher = new Stopwatch();
            stopWatcher.Start();

            lueceneSearchProvider.IndexDirectory = "write_delete_space";
            lueceneSearchProvider.Add(spaceOne);

            var results = lueceneSearchProvider.Query<SpaceObject>("空间");
            Assert.IsTrue(results.Count>= 1);

            lueceneSearchProvider.Delete(spaceOne);
            results = lueceneSearchProvider.Query<SpaceObject>("空间");
            Assert.AreEqual(results.Count, 0);

            Console.WriteLine(results.Count);
        }