diff --git a/lab/elasticsearch/queries.py b/lab/elasticsearch/queries.py index 85ad59c2..83ea9c1a 100644 --- a/lab/elasticsearch/queries.py +++ b/lab/elasticsearch/queries.py @@ -139,7 +139,7 @@ def filter_query( params: QueryParams, ): size = params.pop("size", None) - _from = params.pop("_from", None) + _from = params.pop("from", None) sort = params.pop("sort", None) return Query().build_query( params, diff --git a/lab/elasticsearch/tests/test_queries.py b/lab/elasticsearch/tests/test_queries.py index cbd2ded5..ea100ac7 100644 --- a/lab/elasticsearch/tests/test_queries.py +++ b/lab/elasticsearch/tests/test_queries.py @@ -1,3 +1,5 @@ +from unittest import mock + from .. import queries from ._mock import BASE_SEARCH_PARAMS, BASE_SEARCH_PARAMS_RELATED_QUERY @@ -43,3 +45,9 @@ def test_date_historiogram_agg_query(): } }, } + + +def test_filter_query(): + with mock.patch("lab.elasticsearch.queries.Query.build_query") as mock_build_query: + queries.filter_query({"size": 50, "from": 40, "sort": "desc"}) + mock_build_query.assert_called_with({}, size=50, _from=40, sort="desc")