query: Upgrade to Tantivy 0.13.1 so we don't need the query hack anymore.
parent
e91726e010
commit
785e37fb06
|
@ -13,7 +13,7 @@ crate-type = ["cdylib"]
|
|||
|
||||
[dependencies]
|
||||
chrono = "0.4.15"
|
||||
tantivy = "0.13.0"
|
||||
tantivy = "0.13.1"
|
||||
itertools = "0.9.0"
|
||||
futures = "0.3.5"
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#![allow(clippy::new_ret_no_self)]
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use pyo3::exceptions;
|
||||
use pyo3::prelude::*;
|
||||
use pyo3::types::PyAny;
|
||||
|
@ -339,11 +337,10 @@ impl Index {
|
|||
}
|
||||
let parser =
|
||||
tv::query::QueryParser::for_index(&self.index, default_fields);
|
||||
parser.parse_query(query).map_err(to_pyerr)?;
|
||||
let query = parser.parse_query(query).map_err(to_pyerr)?;
|
||||
|
||||
Ok(Query {
|
||||
query: Arc::new(query.to_owned()),
|
||||
parser,
|
||||
inner: query,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
10
src/query.rs
10
src/query.rs
|
@ -1,20 +1,16 @@
|
|||
use pyo3::prelude::*;
|
||||
use pyo3::PyObjectProtocol;
|
||||
use std::sync::Arc;
|
||||
use tantivy as tv;
|
||||
|
||||
/// Tantivy's Query
|
||||
#[pyclass]
|
||||
pub(crate) struct Query {
|
||||
pub(crate) query: Arc<String>,
|
||||
pub(crate) parser: tv::query::QueryParser,
|
||||
pub(crate) inner: Box<dyn tv::query::Query>,
|
||||
}
|
||||
|
||||
impl Query {
|
||||
pub(crate) fn get(&self) -> Box<dyn tv::query::Query> {
|
||||
self.parser
|
||||
.parse_query(&self.query)
|
||||
.expect("Created a query that returns a parse error")
|
||||
pub(crate) fn get(&self) -> &dyn tv::query::Query {
|
||||
&self.inner
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ impl Searcher {
|
|||
.and_offset(offset)
|
||||
.order_by_u64_field(field);
|
||||
let top_docs_handle = multicollector.add_collector(collector);
|
||||
let ret = self.inner.search(&query.get(), &multicollector);
|
||||
let ret = self.inner.search(query.get(), &multicollector);
|
||||
|
||||
match ret {
|
||||
Ok(mut r) => {
|
||||
|
@ -143,7 +143,7 @@ impl Searcher {
|
|||
} else {
|
||||
let collector = TopDocs::with_limit(limit).and_offset(offset);
|
||||
let top_docs_handle = multicollector.add_collector(collector);
|
||||
let ret = self.inner.search(&query.get(), &multicollector);
|
||||
let ret = self.inner.search(query.get(), &multicollector);
|
||||
|
||||
match ret {
|
||||
Ok(mut r) => {
|
||||
|
|
Loading…
Reference in New Issue