Expose tantivy's AllQuery (#230)
parent
e249241e24
commit
255eb6efba
|
@ -43,4 +43,13 @@ impl Query {
|
||||||
inner: Box::new(inner),
|
inner: Box::new(inner),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Construct a Tantivy's AllQuery
|
||||||
|
#[staticmethod]
|
||||||
|
pub(crate) fn all_query() -> PyResult<Query> {
|
||||||
|
let inner = tv::query::AllQuery {};
|
||||||
|
Ok(Query {
|
||||||
|
inner: Box::new(inner),
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,6 +193,10 @@ class Query:
|
||||||
def term_query(schema: Schema, field_name: str, field_value: Any, index_option: str = "position") -> Query:
|
def term_query(schema: Schema, field_name: str, field_value: Any, index_option: str = "position") -> Query:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def all_query() -> Query:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class Order(Enum):
|
class Order(Enum):
|
||||||
Asc = 1
|
Asc = 1
|
||||||
|
|
|
@ -764,3 +764,10 @@ class TestQuery(object):
|
||||||
_, doc_address = result.hits[0]
|
_, doc_address = result.hits[0]
|
||||||
searched_doc = index.searcher().doc(doc_address)
|
searched_doc = index.searcher().doc(doc_address)
|
||||||
assert searched_doc["title"] == ["The Old Man and the Sea"]
|
assert searched_doc["title"] == ["The Old Man and the Sea"]
|
||||||
|
|
||||||
|
def test_all_query(self, ram_index):
|
||||||
|
index = ram_index
|
||||||
|
query = Query.all_query()
|
||||||
|
|
||||||
|
result = index.searcher().search(query, 10)
|
||||||
|
assert len(result.hits) == 3
|
||||||
|
|
Loading…
Reference in New Issue