Adding delete_all_documents method for IndexWriter (#133)
parent
6340564cd4
commit
4af7d7c45f
|
@ -117,6 +117,12 @@ impl IndexWriter {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Deletes all documents from the index.
|
||||
fn delete_all_documents(&mut self) -> PyResult<()> {
|
||||
self.inner()?.delete_all_documents().map_err(to_pyerr)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The opstamp of the last successful commit.
|
||||
///
|
||||
/// This is the opstamp the index will rollback to if there is a failure
|
||||
|
|
|
@ -488,6 +488,18 @@ class TestClass(object):
|
|||
|
||||
assert orig == pickled
|
||||
|
||||
def test_delete_all_documents(self, ram_index):
|
||||
index = ram_index
|
||||
writer = index.writer()
|
||||
writer.delete_all_documents()
|
||||
writer.commit()
|
||||
|
||||
index.reload()
|
||||
query = index.parse_query("sea whale", ["title", "body"])
|
||||
result = index.searcher().search(query, 10)
|
||||
|
||||
assert len(result.hits) == 0
|
||||
|
||||
|
||||
class TestUpdateClass(object):
|
||||
def test_delete_update(self, ram_index):
|
||||
|
|
Loading…
Reference in New Issue