Esempio n. 1
0
        public void Write100000EntriesAndSearchAtSameTimeNoErrors()
        {
            var docs = CreateIpsumDocs(100000);

            string error   = null;
            int    numDocs = 0;

            using (var reading = AsyncEnumerableEx.CreateTimer(TimeSpan.FromSeconds(0.5))
                                 .Select(t => _indexer.SearchDocuments(i =>
            {
                var query = new TermQuery(new Term("words", "ipsum"));
                return(i.Search(query, 20));
            }))
                                 .Select(d => numDocs += d.Count())
                                 .TakeUntilDisposed(null, t => { if (t.IsFaulted)
                                                                 {
                                                                     error = t.Exception.GetBaseException().Message;
                                                                 }
                                                    }))
            {
                _indexer.WriteToIndex(docs, true).Wait();
            }

            Assert.AreEqual(null, error);
        }
Esempio n. 2
0
        public void WaitsForNewGenerationOnReader()
        {
            var store = new SecureStore(_store);

            using (var readIndexer = new LuceneIndex(store, "testindexer", "basePath", null))
            {
                // Hit the reader initially
                readIndexer.SearchDocuments(s => s.Search(new MatchAllDocsQuery(), int.MaxValue)).Count();

                _indexer.WriteToIndex(CreateIpsumDocs(3000), true).Wait();
                var stream = readIndexer.SearchDocuments(s => s.Search(new MatchAllDocsQuery(), int.MaxValue), true);
                Assert.AreEqual(3000, stream.Count());
            }
        }
Esempio n. 3
0
        public void CanDisposeAndRead()
        {
            _indexer.WriteToIndex(CreateIpsumDocs(2000), true).Wait();
            _indexer.Dispose();
            _indexer = new LuceneIndex(new SecureStore(_store), "testindexer", "basePath", null);

            var number = _indexer.SearchDocuments(ind =>
            {
                var query = new TermQuery(new Term("words", "ipsum"));
                return(ind.Search(query, 20));
            }).ToList();

            Assert.Greater(number.Count, 0);
        }
Esempio n. 4
0
        public void RecreatingWriterDoesNotRefreshIndex()
        {
            LeoTrace.WriteLine = Console.WriteLine;

            _indexer.WriteToIndex(CreateIpsumDocs(3), true).Wait();
            _indexer.Dispose();
            _indexer = new LuceneIndex(new SecureStore(_store), "testindexer", "basePath", null);
            _indexer.WriteToIndex(CreateIpsumDocs(3), true).Wait();
            _indexer.Dispose();
            _indexer = new LuceneIndex(new SecureStore(_store), "testindexer", "basePath", null);

            var number = _indexer.SearchDocuments(s => s.Search(new MatchAllDocsQuery(), int.MaxValue)).Count();

            Assert.AreEqual(6, number);
        }
Esempio n. 5
0
        public void RecreatingWriterDoesNotRefreshIndex()
        {
            LeoTrace.WriteLine = Console.WriteLine;

            _indexer.WriteToIndex(CreateIpsumDocs(3), true).Wait();
            _indexer.Dispose();
            _indexer = new LuceneIndex(new SecureStore(_store), "testindexer", "basePath", null);
            _indexer.WriteToIndex(CreateIpsumDocs(3), true).Wait();
            _indexer.Dispose();
            _indexer = new LuceneIndex(new SecureStore(_store), "testindexer", "basePath", null);

            var number = _indexer.SearchDocuments(s => s.Search(new MatchAllDocsQuery(), int.MaxValue)).Count();
            Assert.AreEqual(6, number);
        }
Esempio n. 6
0
        public void CanDisposeAndRead()
        {
            _indexer.WriteToIndex(CreateIpsumDocs(2000), true).Wait();
            _indexer.Dispose();
            _indexer = new LuceneIndex(new SecureStore(_store), "testindexer", "basePath", null);

            var number = _indexer.SearchDocuments(ind =>
            {
                var query = new TermQuery(new Term("words", "ipsum"));
                return ind.Search(query, 20);
            }).ToList();

            Assert.Greater(number.Count, 0);
        }