Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
96e266e6
M
milvus
项目概览
milvus
/
milvus
接近 1 年 前同步成功
通知
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,发现更多精彩内容 >>
未验证
提交
96e266e6
编写于
9月 17, 2021
作者:
B
binbin
提交者:
GitHub
9月 17, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add test cases for supporting bool expression (#8090)
Signed-off-by:
N
Binbin Lv
<
binbin.lv@zilliz.com
>
上级
cc683614
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
55 addition
and
0 deletion
+55
-0
tests/python_client/testcases/test_search_20.py
tests/python_client/testcases/test_search_20.py
+55
-0
未找到文件。
tests/python_client/testcases/test_search_20.py
浏览文件 @
96e266e6
...
...
@@ -27,6 +27,7 @@ default_search_field = ct.default_float_vec_field_name
default_search_params
=
ct
.
default_search_params
default_int64_field_name
=
ct
.
default_int64_field_name
default_float_field_name
=
ct
.
default_float_field_name
default_bool_field_name
=
ct
.
default_bool_field_name
vectors
=
[[
random
.
random
()
for
_
in
range
(
default_dim
)]
for
_
in
range
(
default_nq
)]
uid
=
"test_search"
...
...
@@ -1574,6 +1575,60 @@ class TestCollectionSearch(TestcaseBase):
ids
=
hits
.
ids
assert
set
(
ids
).
issubset
(
filter_ids_set
)
@
pytest
.
mark
.
tags
(
CaseLabel
.
L2
)
@
pytest
.
mark
.
xfail
(
reason
=
"issue 7910"
)
@
pytest
.
mark
.
parametrize
(
"bool_type"
,
[
True
,
False
,
"true"
,
"false"
,
1
,
0
,
2
])
def
test_search_with_expression_bool
(
self
,
dim
,
auto_id
,
_async
,
bool_type
):
"""
target: test search with different bool expressions
method: search with different bool expressions
expected: searched successfully with correct limit(topK)
"""
# 1. initialize with data
nb
=
1000
collection_w
,
_vectors
,
_
,
insert_ids
=
self
.
init_collection_general
(
prefix
,
True
,
nb
,
is_all_data_type
=
True
,
auto_id
=
auto_id
,
dim
=
dim
)
# 2. create index
index_param
=
{
"index_type"
:
"IVF_FLAT"
,
"metric_type"
:
"L2"
,
"params"
:
{
"nlist"
:
100
}}
collection_w
.
create_index
(
"float_vector"
,
index_param
)
collection_w
.
load
()
# 3. filter result with expression in collection
filter_ids
=
[]
bool_type_cmp
=
bool_type
if
bool_type
==
"true"
:
bool_type_cmp
=
True
if
bool_type
==
"false"
:
bool_type_cmp
=
False
for
i
,
_id
in
enumerate
(
insert_ids
):
if
_vectors
[
0
][
f
"
{
default_bool_field_name
}
"
][
i
]
==
bool_type_cmp
:
filter_ids
.
append
(
_id
)
# 4. search with different expressions
expression
=
f
"
{
default_bool_field_name
}
==
{
bool_type
}
"
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
,
_async
=
_async
,
check_task
=
CheckTasks
.
check_search_results
,
check_items
=
{
"nq"
:
default_nq
,
"ids"
:
insert_ids
,
"limit"
:
min
(
nb
,
len
(
filter_ids
)),
"_async"
:
_async
})
if
_async
:
search_res
.
done
()
search_res
=
search_res
.
result
()
filter_ids_set
=
set
(
filter_ids
)
for
hits
in
search_res
:
ids
=
hits
.
ids
assert
set
(
ids
).
issubset
(
filter_ids_set
)
@
pytest
.
mark
.
tags
(
CaseLabel
.
L2
)
@
pytest
.
mark
.
parametrize
(
"expression"
,
cf
.
gen_normal_expressions_field
(
default_float_field_name
))
def
test_search_with_expression_auto_id
(
self
,
dim
,
expression
,
_async
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录