def reader(self, **kwargs): from whoosh.reading import MultiReader writer = self._get_writer() ramreader = self.ramindex if self.index.is_empty(): return ramreader else: reader = writer.reader(**kwargs) if reader.is_atomic(): reader = MultiReader([reader, ramreader]) else: reader.add_reader(ramreader) return reader
def reader(self, **kwargs): from whoosh.reading import MultiReader reader = self.writer.reader() with self.lock: ramreader = self._get_ram_reader() # If there are in-memory docs, combine the readers if ramreader.doc_count(): if reader.is_atomic(): reader = MultiReader([reader, ramreader]) else: reader.add_reader(ramreader) return reader