Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
c1e8406c
M
milvus
项目概览
milvus
/
milvus
11 个月 前同步成功
通知
260
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
c1e8406c
编写于
4月 30, 2023
作者:
G
Gao
提交者:
GitHub
4月 30, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Override index type as AUTOINDEX when autoindex is enabled (#23744)
Signed-off-by:
N
chasingegg
<
gaoc96@qq.com
>
上级
5a9a86ba
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
133 addition
and
8 deletion
+133
-8
internal/proxy/task_index.go
internal/proxy/task_index.go
+4
-8
internal/proxy/task_index_test.go
internal/proxy/task_index_test.go
+98
-0
tests/python_client/testcases/test_search.py
tests/python_client/testcases/test_search.py
+31
-0
未找到文件。
internal/proxy/task_index.go
浏览文件 @
c1e8406c
...
...
@@ -132,14 +132,10 @@ func (cit *createIndexTask) parseIndexParams() error {
if
isVecIndex
{
specifyIndexType
,
exist
:=
indexParamsMap
[
common
.
IndexTypeKey
]
if
Params
.
AutoIndexConfig
.
Enable
.
GetAsBool
()
{
if
exist
{
if
specifyIndexType
!=
AutoIndexName
{
return
fmt
.
Errorf
(
"IndexType should be %s"
,
AutoIndexName
)
}
}
log
.
Debug
(
"create index trigger AutoIndex"
,
zap
.
String
(
"type"
,
Params
.
AutoIndexConfig
.
AutoIndexTypeName
.
GetValue
()))
// override params
log
.
Info
(
"create index trigger AutoIndex"
,
zap
.
String
(
"original type"
,
specifyIndexType
),
zap
.
String
(
"final type"
,
Params
.
AutoIndexConfig
.
AutoIndexTypeName
.
GetValue
()))
// override params by autoindex
for
k
,
v
:=
range
Params
.
AutoIndexConfig
.
IndexParams
.
GetAsJSONMap
()
{
indexParamsMap
[
k
]
=
v
}
...
...
internal/proxy/task_index_test.go
浏览文件 @
c1e8406c
...
...
@@ -18,6 +18,7 @@ package proxy
import
(
"context"
"encoding/json"
"os"
"testing"
...
...
@@ -358,4 +359,101 @@ func Test_parseIndexParams(t *testing.T) {
},
},
cit
.
newTypeParams
)
})
cit2
:=
&
createIndexTask
{
Condition
:
nil
,
req
:
&
milvuspb
.
CreateIndexRequest
{
Base
:
nil
,
DbName
:
""
,
CollectionName
:
""
,
FieldName
:
""
,
ExtraParams
:
[]
*
commonpb
.
KeyValuePair
{
{
Key
:
"index_type"
,
Value
:
"IVF_FLAT"
,
},
{
Key
:
MetricTypeKey
,
Value
:
"L2"
,
},
{
Key
:
"params"
,
Value
:
"{
\"
nlist
\"
: 100}"
,
},
{
Key
:
DimKey
,
Value
:
"128"
,
},
},
IndexName
:
""
,
},
ctx
:
nil
,
rootCoord
:
nil
,
queryCoord
:
nil
,
result
:
nil
,
isAutoIndex
:
false
,
newIndexParams
:
nil
,
newTypeParams
:
nil
,
collectionID
:
0
,
fieldSchema
:
&
schemapb
.
FieldSchema
{
FieldID
:
101
,
Name
:
"FieldID"
,
IsPrimaryKey
:
false
,
Description
:
"field no.1"
,
DataType
:
schemapb
.
DataType_FloatVector
,
TypeParams
:
[]
*
commonpb
.
KeyValuePair
{
{
Key
:
DimKey
,
Value
:
"128"
,
},
{
Key
:
MetricTypeKey
,
Value
:
"L2"
,
},
}},
}
t
.
Run
(
"parse index params 2"
,
func
(
t
*
testing
.
T
)
{
Params
.
Save
(
Params
.
AutoIndexConfig
.
Enable
.
Key
,
"true"
)
indexParams
:=
map
[
string
]
any
{
"index_type"
:
"HNSW"
,
"M"
:
10
,
"efConstruction"
:
100
,
}
indexParamsStr
,
err
:=
json
.
Marshal
(
indexParams
)
assert
.
NoError
(
t
,
err
)
Params
.
Save
(
Params
.
AutoIndexConfig
.
IndexParams
.
Key
,
string
(
indexParamsStr
))
err
=
cit2
.
parseIndexParams
()
assert
.
NoError
(
t
,
err
)
assert
.
ElementsMatch
(
t
,
[]
*
commonpb
.
KeyValuePair
{
{
Key
:
"index_type"
,
Value
:
"HNSW"
,
},
{
Key
:
MetricTypeKey
,
Value
:
"L2"
,
},
{
Key
:
"M"
,
Value
:
"10"
,
},
{
Key
:
"efConstruction"
,
Value
:
"100"
,
},
{
Key
:
"nlist"
,
Value
:
"100"
,
},
},
cit2
.
newIndexParams
)
assert
.
ElementsMatch
(
t
,
[]
*
commonpb
.
KeyValuePair
{
{
Key
:
DimKey
,
Value
:
"128"
,
},
},
cit2
.
newTypeParams
)
})
}
tests/python_client/testcases/test_search.py
浏览文件 @
c1e8406c
...
...
@@ -1744,6 +1744,37 @@ class TestCollectionSearch(TestcaseBase):
"limit"
:
default_limit
,
"_async"
:
_async
})
@
pytest
.
mark
.
tags
(
CaseLabel
.
L1
)
@
pytest
.
mark
.
parametrize
(
"M"
,
[
4
,
64
])
@
pytest
.
mark
.
parametrize
(
"efConstruction"
,
[
8
,
512
])
def
test_search_HNSW_index_with_redundant_param
(
self
,
M
,
efConstruction
,
auto_id
,
_async
):
"""
target: test search HNSW index with redundant param
method: connect milvus, create collection , insert, create index, load and search
expected: search successfully
"""
dim
=
M
*
4
self
.
_connect
()
collection_w
,
_
,
_
,
insert_ids
,
time_stamp
=
self
.
init_collection_general
(
prefix
,
True
,
partition_num
=
1
,
auto_id
=
auto_id
,
dim
=
dim
,
is_index
=
False
)[
0
:
5
]
HNSW_index_params
=
{
"M"
:
M
,
"efConstruction"
:
efConstruction
,
"nlist"
:
100
}
# nlist is of no use
HNSW_index
=
{
"index_type"
:
"HNSW"
,
"params"
:
HNSW_index_params
,
"metric_type"
:
"L2"
}
collection_w
.
create_index
(
"float_vector"
,
HNSW_index
)
collection_w
.
load
()
search_param
=
{
"metric_type"
:
"L2"
,
"params"
:
{
"ef"
:
32768
,
"nprobe"
:
10
}}
# nprobe is of no use
vectors
=
[[
random
.
random
()
for
_
in
range
(
dim
)]
for
_
in
range
(
default_nq
)]
collection_w
.
search
(
vectors
[:
default_nq
],
default_search_field
,
search_param
,
default_limit
,
default_search_exp
,
_async
=
_async
,
travel_timestamp
=
0
,
check_task
=
CheckTasks
.
check_search_results
,
check_items
=
{
"nq"
:
default_nq
,
"ids"
:
insert_ids
,
"limit"
:
default_limit
,
"_async"
:
_async
})
@
pytest
.
mark
.
tags
(
CaseLabel
.
L1
)
@
pytest
.
mark
.
parametrize
(
"M"
,
[
4
,
64
])
@
pytest
.
mark
.
parametrize
(
"efConstruction"
,
[
8
,
512
])
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录