mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
Add some search cases with expressions (#18813)
Signed-off-by: “nico” <Nico_1986@163.com> Signed-off-by: “nico” <Nico_1986@163.com>
This commit is contained in:
parent
ec02bf2e8a
commit
0a85097ba1
@ -839,8 +839,7 @@ class TestCompactionOperation(TestcaseBase):
|
||||
collection_w = self.collection_insert_multi_segments_one_shard(prefix, num_of_segment=num_of_segment)
|
||||
|
||||
# waiting for auto compaction finished
|
||||
collection_w.collection.compaction_id = 0
|
||||
collection_w.wait_for_compaction_completed()
|
||||
sleep(60)
|
||||
|
||||
collection_w.compact()
|
||||
collection_w.wait_for_compaction_completed()
|
||||
|
||||
@ -1037,6 +1037,7 @@ class TestConnectUserPasswordInvalid(TestcaseBase):
|
||||
self.utility_wrap.create_user(user=user, password="qwaszx0")
|
||||
|
||||
# 3.connect with the created user and wrong password
|
||||
self.connection_wrap.disconnect(alias=connect_name)
|
||||
self.connection_wrap.connect(host=host, port=port, user=user, password=ct.default_password)
|
||||
self.utility_wrap.list_collections(check_task=ct.CheckTasks.err_res,
|
||||
check_items={ct.err_code: 1})
|
||||
|
||||
@ -269,8 +269,6 @@ class TestQueryParams(TestcaseBase):
|
||||
check_task=CheckTasks.check_query_results, check_items={exp_res: res})
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L2)
|
||||
# @pytest.mark.xfail(reason="issue #12210 #7522")
|
||||
@pytest.mark.xfail(reason="https://github.com/milvus-io/milvus/issues/7522")
|
||||
def test_query_expr_by_bool_field(self):
|
||||
"""
|
||||
target: test query by bool field and output bool field
|
||||
|
||||
@ -463,6 +463,31 @@ class TestCollectionSearchInvalid(TestcaseBase):
|
||||
check_items={"err_code": 1,
|
||||
"err_msg": "failed to create query plan"})
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.parametrize("expression", ["int64 like 33", "float LIKE 33"])
|
||||
def test_search_with_expression_invalid_like(self, expression):
|
||||
"""
|
||||
target: test search int64 and float with like
|
||||
method: test search int64 and float with like
|
||||
expected: searched failed
|
||||
"""
|
||||
nb = 1000
|
||||
dim = 8
|
||||
collection_w, _vectors, _, insert_ids = self.init_collection_general(prefix, True,
|
||||
nb, dim=dim,
|
||||
is_index=True)[0:4]
|
||||
index_param = {"index_type": "IVF_FLAT", "metric_type": "L2", "params": {"nlist": 100}}
|
||||
collection_w.create_index("float_vector", index_param)
|
||||
collection_w.load()
|
||||
log.info("test_search_with_expression: searching with expression: %s" % expression)
|
||||
vectors = [[random.random() for _ in range(dim)] for _ in range(default_nq)]
|
||||
search_res, _ = collection_w.search(vectors[:default_nq], default_search_field,
|
||||
default_search_params, nb, expression,
|
||||
check_task=CheckTasks.err_res,
|
||||
check_items={"err_code": 1,
|
||||
"err_msg": "failed to create query plan: cannot parse "
|
||||
"expression: %s" % expression})
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L2)
|
||||
def test_search_partition_invalid_type(self, get_invalid_partition):
|
||||
"""
|
||||
@ -2069,6 +2094,53 @@ class TestCollectionSearch(TestcaseBase):
|
||||
assert (default_int64_field_name and default_float_field_name and default_bool_field_name) \
|
||||
in res[0][0].entity._row_data
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
def test_search_with_comparative_expression(self, _async):
|
||||
"""
|
||||
target: test search with expression comparing two fields
|
||||
method: create a collection, insert data and search with comparative expression
|
||||
expected: search successfully
|
||||
"""
|
||||
#1. create a collection
|
||||
nb = 10
|
||||
dim = 1
|
||||
fields = [cf.gen_int64_field("int64_1"), cf.gen_int64_field("int64_2"),
|
||||
cf.gen_float_vec_field(dim=dim)]
|
||||
schema = cf.gen_collection_schema(fields=fields, primary_field="int64_1")
|
||||
collection_w = self.init_collection_wrap(name="comparison", schema=schema)
|
||||
|
||||
#2. inset data
|
||||
values = pd.Series(data=[i for i in range(0, nb)])
|
||||
dataframe = pd.DataFrame({"int64_1": values, "int64_2": values,
|
||||
ct.default_float_vec_field_name: cf.gen_vectors(nb, dim)})
|
||||
insert_res = collection_w.insert(dataframe)[0]
|
||||
|
||||
insert_ids = []
|
||||
filter_ids = []
|
||||
insert_ids.extend(insert_res.primary_keys)
|
||||
for _id in enumerate(insert_ids):
|
||||
filter_ids.extend(_id)
|
||||
|
||||
#3. search with expression
|
||||
collection_w.load()
|
||||
expression = "int64_1 <= int64_2"
|
||||
vectors = [[random.random() for _ in range(dim)] for _ in range(default_nq)]
|
||||
res = collection_w.search(vectors[:nq], default_search_field,
|
||||
default_search_params, default_limit,
|
||||
expression, _async=_async,
|
||||
check_task=CheckTasks.check_search_results,
|
||||
check_items={"nq": nq,
|
||||
"ids": insert_ids,
|
||||
"limit": default_limit,
|
||||
"_async": _async})[0]
|
||||
if _async:
|
||||
res.done()
|
||||
res = res.result()
|
||||
filter_ids_set = set(filter_ids)
|
||||
for hits in res:
|
||||
ids = hits.ids
|
||||
assert set(ids).issubset(filter_ids_set)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L2)
|
||||
def test_search_with_output_fields_empty(self, nb, nq, dim, auto_id, _async):
|
||||
"""
|
||||
|
||||
@ -1776,6 +1776,7 @@ class TestUtilityUserPassword(TestcaseBase):
|
||||
user = "nico"
|
||||
password = "wertyu567"
|
||||
self.utility_wrap.create_user(user=user, password=password)
|
||||
self.connection_wrap.disconnect(alias=DefaultConfig.DEFAULT_USING)
|
||||
self.connection_wrap.connect(host=host, port=port, user=user, password=password,
|
||||
check_task=ct.CheckTasks.ccr)
|
||||
self.utility_wrap.list_collections()
|
||||
@ -1794,6 +1795,7 @@ class TestUtilityUserPassword(TestcaseBase):
|
||||
user = "robot2048"
|
||||
self.utility_wrap.create_user(user=user, password=old_password)
|
||||
self.utility_wrap.reset_password(user=user, old_password=old_password, new_password=new_password)
|
||||
self.connection_wrap.disconnect(alias=DefaultConfig.DEFAULT_USING)
|
||||
self.connection_wrap.connect(host=host, port=port, user=user,
|
||||
password=new_password, check_task=ct.CheckTasks.ccr)
|
||||
self.utility_wrap.list_collections()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user