Using tantivy 0.11

master
Paul Masurel 2019-12-17 23:23:53 +09:00
parent f8d43502c3
commit 41cdad4157
3 changed files with 23 additions and 7 deletions

View File

@ -11,8 +11,9 @@ crate-type = ["cdylib"]
[dependencies] [dependencies]
chrono = "0.4" chrono = "0.4"
tantivy = { git = "https://github.com/tantivy-search/tantivy", branch = "master" } tantivy = "0.11"
itertools = "0.8" itertools = "0.8"
futures = "0.3"
[dependencies.pyo3] [dependencies.pyo3]
version = "0.8" version = "0.8"

View File

@ -25,6 +25,10 @@ fn value_to_py(py: Python, value: &Value) -> PyResult<PyObject> {
Value::I64(num) => (*num).into_py(py), Value::I64(num) => (*num).into_py(py),
Value::F64(num) => (*num).into_py(py), Value::F64(num) => (*num).into_py(py),
Value::Bytes(b) => b.to_object(py), Value::Bytes(b) => b.to_object(py),
Value::PreTokStr(pretoken) => {
// TODO implement me
unimplemented!();
}
Value::Date(d) => PyDateTime::new( Value::Date(d) => PyDateTime::new(
py, py,
d.year(), d.year(),
@ -50,6 +54,10 @@ fn value_to_string(value: &Value) -> String {
Value::Bytes(bytes) => format!("{:?}", bytes), Value::Bytes(bytes) => format!("{:?}", bytes),
Value::Date(d) => format!("{:?}", d), Value::Date(d) => format!("{:?}", d),
Value::Facet(facet) => facet.to_string(), Value::Facet(facet) => facet.to_string(),
Value::PreTokStr(pretok) => {
// TODO implement me
unimplemented!();
}
} }
} }

View File

@ -79,9 +79,11 @@ impl IndexWriter {
/// Detect and removes the files that are not used by the index anymore. /// Detect and removes the files that are not used by the index anymore.
fn garbage_collect_files(&mut self) -> PyResult<()> { fn garbage_collect_files(&mut self) -> PyResult<()> {
self.inner_index_writer use futures::executor::block_on;
.garbage_collect_files() block_on(self.inner_index_writer
.map_err(to_pyerr) .garbage_collect_files())
.map_err(to_pyerr)?;
Ok(())
} }
/// The opstamp of the last successful commit. /// The opstamp of the last successful commit.
@ -130,6 +132,12 @@ impl IndexWriter {
field_name 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())) Ok(self.inner_index_writer.delete_term(term.clone()))
} }
@ -332,11 +340,10 @@ impl Index {
} }
} }
} else { } else {
for (field_id, field_entry) in for (field, field_entry) in self.index.schema().fields()
self.index.schema().fields().iter().enumerate()
{ {
if field_entry.is_indexed() { if field_entry.is_indexed() {
default_fields.push(Field(field_id as u32)); default_fields.push(field);
} }
} }
} }