Example #1
0
def test_multi(tempdir):
    indexers = engine.Indexer(tempdir), engine.Indexer()
    searcher = engine.MultiSearcher(
        [indexers[0].indexReader, indexers[1].directory])
    pytest.raises(TypeError, getattr, searcher, 'timestamp')
    assert engine.MultiSearcher([indexers[0].directory]).timestamp
    assert [reader.refCount for reader in searcher.indexReaders] == [2, 1]
    assert searcher.reopen() is searcher
    indexers[0].add()
    indexers[0].commit()
    assert [reader.refCount for reader in searcher.indexReaders] == [1, 1]
    searcher, previous = searcher.reopen(), searcher
    assert searcher.version > previous.version
    assert [reader.refCount for reader in searcher.indexReaders] == [1, 2]
    del previous
    assert [reader.refCount for reader in searcher.indexReaders] == [1, 1]
Example #2
0
 def __init__(self, *directories, **kwargs):
     if len(directories) > 1:
         self.searcher = engine.MultiSearcher(directories, **kwargs)
     else:
         self.searcher = engine.IndexSearcher(*directories, **kwargs)
     self.updated = time.time()
     self.query_map = {}
Example #3
0
 def __init__(self, *directories, **kwargs):
     self.urls = collections.deque(kwargs.pop('urls', ()))
     if self.urls:
         engine.IndexWriter(*directories).close()
     self.searcher = engine.MultiSearcher(
         directories, **
         kwargs) if len(directories) > 1 else engine.IndexSearcher(
             *directories, **kwargs)
     self.updated = time.time()
     self.query_map = {}