Skip to content

Commit 255eb6e

Browse files
authored
Expose tantivy's AllQuery (#230)
1 parent e249241 commit 255eb6e

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/query.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,13 @@ impl Query {
4343
inner: Box::new(inner),
4444
})
4545
}
46+
47+
/// Construct a Tantivy's AllQuery
48+
#[staticmethod]
49+
pub(crate) fn all_query() -> PyResult<Query> {
50+
let inner = tv::query::AllQuery {};
51+
Ok(Query {
52+
inner: Box::new(inner),
53+
})
54+
}
4655
}

tantivy/tantivy.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ class Query:
193193
def term_query(schema: Schema, field_name: str, field_value: Any, index_option: str = "position") -> Query:
194194
pass
195195

196+
@staticmethod
197+
def all_query() -> Query:
198+
pass
199+
196200

197201
class Order(Enum):
198202
Asc = 1

tests/tantivy_test.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,3 +764,10 @@ def test_term_query(self, ram_index):
764764
_, doc_address = result.hits[0]
765765
searched_doc = index.searcher().doc(doc_address)
766766
assert searched_doc["title"] == ["The Old Man and the Sea"]
767+
768+
def test_all_query(self, ram_index):
769+
index = ram_index
770+
query = Query.all_query()
771+
772+
result = index.searcher().search(query, 10)
773+
assert len(result.hits) == 3

0 commit comments

Comments
 (0)