mirror of https://github.com/milvus-io/milvus.git
Add search and collection cases when dim=1 (#18484)
Signed-off-by: “nico” <Nico_1986@163.com>pull/18492/head
parent
ab461c6e5e
commit
efc5406e78
|
@ -46,6 +46,7 @@ float_field_desc = "float type field"
|
|||
float_vec_field_desc = "float vector type field"
|
||||
binary_vec_field_desc = "binary vector type field"
|
||||
max_dim = 32768
|
||||
min_dim = 1
|
||||
gracefulTime = 1
|
||||
default_nlist = 128
|
||||
compact_segment_num_threshold = 4
|
||||
|
|
|
@ -1502,6 +1502,22 @@ class TestCollectionCountBinary(TestcaseBase):
|
|||
collection_w.create_index(ct.default_binary_vec_field_name, default_binary_index_params)
|
||||
assert collection_w.num_entities == insert_count
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.parametrize("auto_id",[True, False])
|
||||
def test_binary_collection_with_min_dim(self, auto_id):
|
||||
"""
|
||||
target: test binary collection when dim=1
|
||||
method: creat collection and set dim=1
|
||||
expected: check error message successfully
|
||||
"""
|
||||
self._connect()
|
||||
dim = 1
|
||||
c_schema = cf.gen_default_binary_collection_schema(auto_id=auto_id, dim=dim)
|
||||
collection_w = self.init_collection_wrap(schema=c_schema,
|
||||
check_task=CheckTasks.err_res,
|
||||
check_items={"err_code": 1,
|
||||
"err_msg": f"invalid dimension: {dim}. should be multiple of 8."})
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L2)
|
||||
def test_collection_count_no_entities(self):
|
||||
"""
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import multiprocessing
|
||||
import numbers
|
||||
import random
|
||||
|
||||
import pytest
|
||||
from time import sleep
|
||||
|
@ -16,6 +17,7 @@ from pymilvus.orm.types import CONSISTENCY_STRONG, CONSISTENCY_BOUNDED, CONSISTE
|
|||
prefix = "search_collection"
|
||||
search_num = 10
|
||||
max_dim = ct.max_dim
|
||||
min_dim = ct.min_dim
|
||||
epsilon = ct.epsilon
|
||||
gracefulTime = ct.gracefulTime
|
||||
default_nb = ct.default_nb
|
||||
|
@ -1207,6 +1209,30 @@ class TestCollectionSearch(TestcaseBase):
|
|||
"limit": nq,
|
||||
"_async": _async})
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
def test_search_min_dim(self, auto_id, _async):
|
||||
"""
|
||||
target: test search with min configuration
|
||||
method: create connection, collection, insert and search with dim=1
|
||||
expected: search successfully
|
||||
"""
|
||||
# 1. initialize with data
|
||||
collection_w, _, _, insert_ids = self.init_collection_general(prefix, True, 100,
|
||||
auto_id=auto_id,
|
||||
dim=min_dim)[0:4]
|
||||
# 2. search
|
||||
nq = 2
|
||||
log.info("test_search_min_dim: searching collection %s" % collection_w.name)
|
||||
vectors = [[random.random() for _ in range(min_dim)] for _ in range(nq)]
|
||||
collection_w.search(vectors[:nq], default_search_field,
|
||||
default_search_params, nq,
|
||||
default_search_exp, _async=_async,
|
||||
check_task=CheckTasks.check_search_results,
|
||||
check_items={"nq": nq,
|
||||
"ids": insert_ids,
|
||||
"limit": nq,
|
||||
"_async": _async})
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.parametrize("index, params",
|
||||
zip(ct.all_index_types[:9],
|
||||
|
@ -1247,6 +1273,47 @@ class TestCollectionSearch(TestcaseBase):
|
|||
"limit": default_limit,
|
||||
"_async": _async})
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L2)
|
||||
@pytest.mark.skip(reason="issue #18479")
|
||||
@pytest.mark.parametrize("index, params",
|
||||
zip(ct.all_index_types[:9],
|
||||
ct.default_index_params[:9]))
|
||||
def test_search_after_different_index_with_min_dim(self, index, params, auto_id, _async):
|
||||
"""
|
||||
target: test search after different index with min dim
|
||||
method: test search after different index and corresponding search params with dim = 1
|
||||
expected: search successfully with limit(topK)
|
||||
"""
|
||||
# 1. initialize with data
|
||||
collection_w, _, _, insert_ids, time_stamp = self.init_collection_general(prefix, True, 5000,
|
||||
partition_num=1,
|
||||
auto_id=auto_id,
|
||||
dim=min_dim, is_index=True)[0:5]
|
||||
# 2. create index and load
|
||||
if params.get("m"):
|
||||
if (min_dim % params["m"]) != 0:
|
||||
params["m"] = min_dim // 4
|
||||
if params.get("PQM"):
|
||||
if (min_dim % params["PQM"]) != 0:
|
||||
params["PQM"] = min_dim // 4
|
||||
default_index = {"index_type": index, "params": params, "metric_type": "L2"}
|
||||
collection_w.create_index("float_vector", default_index)
|
||||
collection_w.load()
|
||||
# 3. search
|
||||
search_params = cf.gen_search_param(index)
|
||||
vectors = [[random.random() for _ in range(min_dim)] for _ in range(default_nq)]
|
||||
for search_param in search_params:
|
||||
log.info("Searching with search params: {}".format(search_param))
|
||||
collection_w.search(vectors[:default_nq], default_search_field,
|
||||
search_param, default_limit,
|
||||
default_search_exp, _async=_async,
|
||||
travel_timestamp=time_stamp,
|
||||
check_task=CheckTasks.check_search_results,
|
||||
check_items={"nq": default_nq,
|
||||
"ids": insert_ids,
|
||||
"limit": default_limit,
|
||||
"_async": _async})
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L2)
|
||||
@pytest.mark.parametrize("index, params",
|
||||
zip(ct.all_index_types[:9],
|
||||
|
|
Loading…
Reference in New Issue