diff --git a/Cargo.toml b/Cargo.toml index 7bc38b7..e00beef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,8 +11,9 @@ crate-type = ["cdylib"] [dependencies] chrono = "0.4" -tantivy = { git = "https://github.com/tantivy-search/tantivy", branch = "master" } +tantivy = "0.11" itertools = "0.8" +futures = "0.3" [dependencies.pyo3] version = "0.8" diff --git a/src/document.rs b/src/document.rs index 58a58ea..601f3f0 100644 --- a/src/document.rs +++ b/src/document.rs @@ -25,6 +25,10 @@ fn value_to_py(py: Python, value: &Value) -> PyResult { Value::I64(num) => (*num).into_py(py), Value::F64(num) => (*num).into_py(py), Value::Bytes(b) => b.to_object(py), + Value::PreTokStr(pretoken) => { + // TODO implement me + unimplemented!(); + } Value::Date(d) => PyDateTime::new( py, d.year(), @@ -50,6 +54,10 @@ fn value_to_string(value: &Value) -> String { Value::Bytes(bytes) => format!("{:?}", bytes), Value::Date(d) => format!("{:?}", d), Value::Facet(facet) => facet.to_string(), + Value::PreTokStr(pretok) => { + // TODO implement me + unimplemented!(); + } } } diff --git a/src/index.rs b/src/index.rs index fd80297..c20af98 100644 --- a/src/index.rs +++ b/src/index.rs @@ -79,9 +79,11 @@ impl IndexWriter { /// Detect and removes the files that are not used by the index anymore. fn garbage_collect_files(&mut self) -> PyResult<()> { - self.inner_index_writer - .garbage_collect_files() - .map_err(to_pyerr) + use futures::executor::block_on; + block_on(self.inner_index_writer + .garbage_collect_files()) + .map_err(to_pyerr)?; + Ok(()) } /// The opstamp of the last successful commit. @@ -130,6 +132,12 @@ impl IndexWriter { field_name ))) } + Value::PreTokStr(pretok) => { + return Err(exceptions::ValueError::py_err(format!( + "Field `{}` is pretokenized. This is not authorized for delete.", + field_name + ))) + } }; Ok(self.inner_index_writer.delete_term(term.clone())) } @@ -332,11 +340,10 @@ impl Index { } } } else { - for (field_id, field_entry) in - self.index.schema().fields().iter().enumerate() + for (field, field_entry) in self.index.schema().fields() { if field_entry.is_indexed() { - default_fields.push(Field(field_id as u32)); + default_fields.push(field); } } }