Skip to content

Add pagination feature for v0.30.0 #595

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

Merged
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
28 changes: 28 additions & 0 deletions tests/index/test_index_search_meilisearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ def test_basic_search(index_with_documents):
response = index_with_documents().search("How to Train Your Dragon")
assert isinstance(response, dict)
assert response["hits"][0]["id"] == "166428"
assert response["estimatedTotalHits"] is not None
assert "hitsPerPage" is not response


def test_basic_search_with_empty_params(index_with_documents):
Expand Down Expand Up @@ -413,3 +415,29 @@ def test_custom_search_params_with_matching_strategy_last(index_with_documents):

assert isinstance(response, dict)
assert len(response["hits"]) > 1


def test_custom_search_params_with_pagination_parameters(index_with_documents):
"""Tests search with matching strategy param set to last"""
response = index_with_documents().search("", {"hitsPerPage": 1, "page": 1})

assert isinstance(response, dict)
assert len(response["hits"]) == 1
assert response["hitsPerPage"] == 1
assert response["page"] == 1
assert response["totalPages"] is not None
assert response["totalHits"] is not None
assert "estimatedTotalHits" is not response


def test_custom_search_params_with_pagination_parameters_at_zero(index_with_documents):
"""Tests search with matching strategy param set to last"""
response = index_with_documents().search("", {"hitsPerPage": 0, "page": 0})

assert isinstance(response, dict)
assert len(response["hits"]) == 0
assert response["hitsPerPage"] == 0
assert response["page"] == 0
assert response["totalPages"] is not None
assert response["totalHits"] is not None
assert "estimatedTotalHits" is not response