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

Expose tantivy's AllQuery #230

Merged
merged 2 commits into from
Mar 31, 2024
Merged
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,13 @@ impl Query {
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),
})
}
}
4 changes: 4 additions & 0 deletions tantivy/tantivy.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ class Query:
def term_query(schema: Schema, field_name: str, field_value: Any, index_option: str = "position") -> Query:
pass

@staticmethod
def all_query() -> Query:
pass


class Order(Enum):
Asc = 1
Expand Down
7 changes: 7 additions & 0 deletions tests/tantivy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,3 +764,10 @@ def test_term_query(self, ram_index):
_, doc_address = result.hits[0]
searched_doc = index.searcher().doc(doc_address)
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