コード例 #1
0
        public void should_query_with_special_string()
        {
            BaseSearchProvider lueceneBaseSearchProvider = 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 = "******",
            };

            lueceneBaseSearchProvider.Add(spaceOne);

            var results = lueceneBaseSearchProvider.Query <SpaceObject>("*****");

            Assert.AreEqual(results.Count, 0);

            results = lueceneBaseSearchProvider.Query <SpaceObject>("#@RF**__++||");
            Assert.AreEqual(results.Count, 0);

            results = lueceneBaseSearchProvider.Query <SpaceObject>(" || __    ");
            Assert.AreEqual(results.Count, 0);
        }
コード例 #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);
        }
コード例 #3
0
        public void should_query_with_special_string()
        {
            BaseSearchProvider lueceneBaseSearchProvider = 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 = "******",

            };
            lueceneBaseSearchProvider.Add(spaceOne);

            var results = lueceneBaseSearchProvider.Query<SpaceObject>("*****");
            Assert.AreEqual(results.Count, 0);

            results = lueceneBaseSearchProvider.Query<SpaceObject>("#@RF**__++||");
            Assert.AreEqual(results.Count, 0);

            results = lueceneBaseSearchProvider.Query<SpaceObject>(" || __    ");
            Assert.AreEqual(results.Count, 0);
        }
コード例 #4
0
        public void test_with_write_index_singleton()
        {
            BaseSearchProvider lueceneBaseSearchProvider = 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 = "******",
            };

            var spaceTwo = 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();

            lueceneBaseSearchProvider.IndexDirectory = "tempspace";
            lueceneBaseSearchProvider.Add(spaceOne);
            lueceneBaseSearchProvider.Add(spaceTwo);

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

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

            Console.WriteLine(results.Count);
        }
コード例 #5
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);
        }
コード例 #6
0
        public void test_with_write_index_singleton()
        {
            BaseSearchProvider lueceneBaseSearchProvider = 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 = "******",

            };

            var spaceTwo = 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();

            lueceneBaseSearchProvider.IndexDirectory = "tempspace";
            lueceneBaseSearchProvider.Add(spaceOne);
            lueceneBaseSearchProvider.Add(spaceTwo);

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

            Console.WriteLine(results.Count);
        }