mirror of https://github.com/milvus-io/milvus.git
Add test cases of search pagination in case offset >= num_entities (#21252)
Signed-off-by: nico <cheng.yuan@zilliz.com> Signed-off-by: nico <cheng.yuan@zilliz.com>pull/21021/head
parent
0954014c6d
commit
ee7fddb6d9
|
@ -1035,6 +1035,22 @@ class TestQueryParams(TestcaseBase):
|
|||
check_items={exp_res: res})[0]
|
||||
assert query_res == res
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L2)
|
||||
@pytest.mark.skip("issue #21223")
|
||||
@pytest.mark.parametrize("offset", [3000, 5000])
|
||||
def test_query_pagination_with_offset_over_num_entities(self, offset):
|
||||
"""
|
||||
target: test query pagination with offset over num_entities
|
||||
method: query with offset over num_entities
|
||||
expected: return an empty list
|
||||
"""
|
||||
# create collection, insert default_nb, load collection
|
||||
collection_w, vectors = self.init_collection_general(prefix, insert_data=True)[0:2]
|
||||
int_values = vectors[0][ct.default_int64_field_name].values.tolist()
|
||||
pos = 10
|
||||
term_expr = f'{ct.default_int64_field_name} in {int_values[10: pos + 10]}'
|
||||
collection_w.query(term_expr, offset=offset, limit=10)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L2)
|
||||
@pytest.mark.parametrize("limit", ["12 s", " ", [0, 1], {2}])
|
||||
def test_query_pagination_with_invalid_limit_type(self, limit):
|
||||
|
|
|
@ -4118,14 +4118,14 @@ class TestsearchPagination(TestcaseBase):
|
|||
assert set(search_res[0].ids) == set(res[0].ids[offset:])
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L2)
|
||||
def test_search_pagination_empty(self, offset, dim, auto_id, _async):
|
||||
def test_search_pagination_empty(self, offset, auto_id, _async):
|
||||
"""
|
||||
target: test search pagination empty
|
||||
method: connect, create collection, insert data and search
|
||||
expected: search successfully
|
||||
"""
|
||||
# 1. initialize without data
|
||||
collection_w = self.init_collection_general(prefix, True, auto_id=auto_id, dim=dim)[0]
|
||||
collection_w = self.init_collection_general(prefix, True, auto_id=auto_id, dim=default_dim)[0]
|
||||
# 2. search collection without data
|
||||
search_param = {"metric_type": "L2", "params": {"nprobe": 10}, "offset": offset}
|
||||
search_res = collection_w.search([], default_search_field, search_param,
|
||||
|
@ -4138,6 +4138,27 @@ class TestsearchPagination(TestcaseBase):
|
|||
search_res = search_res.result()
|
||||
assert len(search_res) == 0
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L2)
|
||||
@pytest.mark.parametrize("offset", [3000, 5000])
|
||||
def test_search_pagination_with_offset_over_num_entities(self, offset):
|
||||
"""
|
||||
target: test search pagination with offset over num_entities
|
||||
method: create connection, collection, insert 3000 entities and search with offset over 3000
|
||||
expected: return an empty list
|
||||
"""
|
||||
# 1. initialize
|
||||
collection_w = self.init_collection_general(prefix, True, dim=default_dim)[0]
|
||||
# 2. search
|
||||
search_param = {"metric_type": "L2", "params": {"nprobe": 10}, "offset": offset}
|
||||
vectors = [[random.random() for _ in range(default_dim)] for _ in range(default_nq)]
|
||||
res = collection_w.search(vectors[:default_nq], default_search_field,
|
||||
search_param, default_limit,
|
||||
default_search_exp,
|
||||
check_task=CheckTasks.check_search_results,
|
||||
check_items={"nq": default_nq,
|
||||
"limit": 0})[0]
|
||||
assert res[0].ids == []
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L2)
|
||||
@pytest.mark.parametrize("index, params",
|
||||
zip(ct.all_index_types[:7],
|
||||
|
|
Loading…
Reference in New Issue