Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
7e7941af
M
milvus
项目概览
milvus
/
milvus
11 个月 前同步成功
通知
261
Star
22476
Fork
2472
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
milvus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
7e7941af
编写于
6月 01, 2022
作者:
J
jingkl
提交者:
GitHub
6月 01, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[test]Add the testcase with query and search (#17320)
Signed-off-by:
N
jingkl
<
jingjing.jia@zilliz.com
>
上级
3ccc9153
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
113 addition
and
0 deletion
+113
-0
tests/python_client/testcases/test_delete.py
tests/python_client/testcases/test_delete.py
+46
-0
tests/python_client/testcases/test_query.py
tests/python_client/testcases/test_query.py
+26
-0
tests/python_client/testcases/test_search.py
tests/python_client/testcases/test_search.py
+41
-0
未找到文件。
tests/python_client/testcases/test_delete.py
浏览文件 @
7e7941af
...
...
@@ -1665,3 +1665,49 @@ class TestDeleteString(TestcaseBase):
collection_w
.
load
()
error
=
{
ct
.
err_code
:
0
,
ct
.
err_msg
:
f
"failed to create expr plan, expr =
{
default_invaild_string_exp
}
"
}
collection_w
.
delete
(
expr
=
default_invaild_string_exp
,
check_task
=
CheckTasks
.
err_res
,
check_items
=
error
)
@
pytest
.
mark
.
tags
(
CaseLabel
.
L1
)
@
pytest
.
mark
.
parametrize
(
"to_query"
,
[
True
,
False
])
def
test_delete_insert_same_id_sealed_string
(
self
,
to_query
):
"""
target: test insert same id entity after delete from sealed data
method: 1.create and insert with flush, string is pk field
2.load and query with the id
3.delete the id entity
4.insert new entity with the same id and flush
5.query the id
expected: Verify that the query gets the newly inserted entity
"""
# init collection and insert data without flush
schema
=
cf
.
gen_string_pk_default_collection_schema
()
collection_w
=
self
.
init_collection_wrap
(
cf
.
gen_unique_str
(
prefix
),
schema
=
schema
)
# insert
df
=
cf
.
gen_default_dataframe_data
(
1000
)
collection_w
.
insert
(
df
)
log
.
debug
(
collection_w
.
num_entities
)
# load and query
collection_w
.
load
()
res
=
df
.
iloc
[:
1
,
2
:
3
].
to_dict
(
'records'
)
default_search_params
=
{
"metric_type"
:
"L2"
,
"params"
:
{
"nprobe"
:
16
}}
collection_w
.
search
(
data
=
[
df
[
ct
.
default_float_vec_field_name
][
0
]],
anns_field
=
ct
.
default_float_vec_field_name
,
param
=
default_search_params
,
limit
=
1
)
collection_w
.
query
(
default_string_expr
,
check_task
=
CheckTasks
.
check_query_results
,
check_items
=
{
'exp_res'
:
res
})
# delete
collection_w
.
delete
(
default_string_expr
)
if
to_query
:
collection_w
.
query
(
default_string_expr
,
check_task
=
CheckTasks
.
check_query_empty
)
# re-insert
df_new
=
cf
.
gen_default_dataframe_data
(
nb
=
1
)
collection_w
.
insert
(
df_new
)
log
.
debug
(
collection_w
.
num_entities
)
# re-query
res
=
df_new
.
iloc
[[
0
],
[
2
,
3
]].
to_dict
(
'records'
)
collection_w
.
query
(
default_string_expr
,
output_fields
=
[
ct
.
default_float_vec_field_name
],
check_task
=
CheckTasks
.
check_query_results
,
check_items
=
{
'exp_res'
:
res
,
'primary_field'
:
ct
.
default_string_field_name
,
'with_vec'
:
True
})
collection_w
.
search
(
data
=
[
df_new
[
ct
.
default_float_vec_field_name
][
0
]],
anns_field
=
ct
.
default_float_vec_field_name
,
param
=
default_search_params
,
limit
=
1
)
tests/python_client/testcases/test_query.py
浏览文件 @
7e7941af
...
...
@@ -1304,3 +1304,29 @@ class TestqueryString(TestcaseBase):
collection_w
.
query
(
expression
,
check_task
=
CheckTasks
.
err_res
,
check_items
=
{
ct
.
err_code
:
1
,
ct
.
err_msg
:
"like operation on non-string field is unsupported"
}
)
@
pytest
.
mark
.
tags
(
CaseLabel
.
L1
)
def
test_query_compare_two_fields
(
self
):
"""
target: test query with
method: specify string primary field, compare two fields
expected: verify query successfully
"""
collection_w
=
self
.
init_collection_general
(
prefix
,
insert_data
=
True
,
primary_field
=
ct
.
default_string_field_name
)[
0
]
res
=
[]
expression
=
'float > int64'
output_fields
=
[
default_int_field_name
,
default_float_field_name
,
default_string_field_name
]
collection_w
.
query
(
expression
,
output_fields
=
output_fields
,
check_task
=
CheckTasks
.
check_query_results
,
check_items
=
{
exp_res
:
res
})
@
pytest
.
mark
.
tags
(
CaseLabel
.
L1
)
def
test_query_compare_invalid_fields
(
self
):
"""
target: test query with
method: specify string primary field, compare string and int field
expected: raise error
"""
collection_w
=
self
.
init_collection_general
(
prefix
,
insert_data
=
True
,
primary_field
=
ct
.
default_string_field_name
)[
0
]
expression
=
'varchar == int64'
collection_w
.
query
(
expression
,
check_task
=
CheckTasks
.
err_res
,
check_items
=
{
ct
.
err_code
:
1
,
ct
.
err_msg
:
f
' cannot parse expression:
{
expression
}
'
})
tests/python_client/testcases/test_search.py
浏览文件 @
7e7941af
...
...
@@ -46,6 +46,8 @@ entity = gen_entities(1, is_normal=True)
entities
=
gen_entities
(
default_nb
,
is_normal
=
True
)
raw_vectors
,
binary_entities
=
gen_binary_entities
(
default_nb
)
default_query
,
_
=
gen_search_vectors_params
(
field_name
,
entities
,
default_top_k
,
nq
)
index_name1
=
cf
.
gen_unique_str
(
"float"
)
index_name2
=
cf
.
gen_unique_str
(
"varhar"
)
class
TestCollectionSearchInvalid
(
TestcaseBase
):
...
...
@@ -3021,4 +3023,43 @@ class TestsearchString(TestcaseBase):
"ids"
:
insert_ids
,
"limit"
:
1
,
"_async"
:
_async
}
)
@
pytest
.
mark
.
tags
(
CaseLabel
.
L1
)
def
test_search_all_index_with_compare_expr
(
self
,
_async
):
"""
target: test delete after creating index
method: 1.create collection , insert data, primary_field is string field
2.create string and float index ,delete entities, query
3.search
expected: assert index and deleted id not in search result
"""
# create collection, insert tmp_nb, flush and load
collection_w
,
vectors
,
_
,
insert_ids
=
self
.
init_collection_general
(
prefix
,
insert_data
=
True
,
primary_field
=
ct
.
default_string_field_name
)[
0
:
4
]
# create index
index_params_one
=
{
"index_type"
:
"IVF_SQ8"
,
"metric_type"
:
"L2"
,
"params"
:
{
"nlist"
:
64
}}
collection_w
.
create_index
(
ct
.
default_float_vec_field_name
,
index_params_one
,
index_name
=
index_name1
)
index_params_two
=
{}
collection_w
.
create_index
(
ct
.
default_string_field_name
,
index_params
=
index_params_two
,
index_name
=
index_name2
)
assert
collection_w
.
has_index
(
index_name
=
index_name2
)
collection_w
.
release
()
collection_w
.
load
()
# delete entity
expr
=
'float >= int64'
# search with id 0 vectors
vectors
=
[[
random
.
random
()
for
_
in
range
(
default_dim
)]
for
_
in
range
(
default_nq
)]
output_fields
=
[
default_int64_field_name
,
default_float_field_name
,
default_string_field_name
]
collection_w
.
search
(
vectors
[:
default_nq
],
default_search_field
,
default_search_params
,
default_limit
,
expr
,
output_fields
=
output_fields
,
_async
=
_async
,
travel_timestamp
=
0
,
check_task
=
CheckTasks
.
check_search_results
,
check_items
=
{
"nq"
:
default_nq
,
"ids"
:
insert_ids
,
"limit"
:
default_limit
,
"_async"
:
_async
}
)
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录