Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lints from recent PR #248

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/query.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
use crate::{make_term, Schema};
use pyo3::{exceptions, prelude::*, types::PyAny, types::PyString, types::PyTuple};
use pyo3::{
exceptions, prelude::*, types::PyAny, types::PyString, types::PyTuple,
};
use tantivy as tv;

/// Custom Tuple struct to represent a pair of Occur and Query
/// for the BooleanQuery
struct OccurQueryPair(Occur, Query);

impl <'source> FromPyObject<'source> for OccurQueryPair {
impl<'source> FromPyObject<'source> for OccurQueryPair {
fn extract(ob: &'source PyAny) -> PyResult<Self> {
let tuple = ob.downcast::<PyTuple>()?;
let occur = tuple.get_item(0)?.extract()?;
Expand All @@ -16,7 +18,6 @@ impl <'source> FromPyObject<'source> for OccurQueryPair {
}
}


/// Tantivy's Occur
#[pyclass(frozen, module = "tantivy.tantivy")]
#[derive(Clone)]
Expand Down Expand Up @@ -137,13 +138,13 @@ impl Query {
#[staticmethod]
#[pyo3(signature = (subqueries))]
pub(crate) fn boolean_query(
subqueries: Vec<(Occur, Query)>
subqueries: Vec<(Occur, Query)>,
) -> PyResult<Query> {
let dyn_subqueries = subqueries
.into_iter()
.map(|(occur, query)| (occur.into(), query.inner.box_clone()))
.collect::<Vec<_>>();

let inner = tv::query::BooleanQuery::from(dyn_subqueries);

Ok(Query {
Expand Down
Loading