mirror of https://github.com/milvus-io/milvus.git
enhance: add new optimize param for queryhook (#29495)
add a flag to indicate if we use search param optimizations, default is on --------- Signed-off-by: chasingegg <chao.gao@zilliz.com>pull/29554/head
parent
44ed0dff6a
commit
8a630f733a
|
@ -12,6 +12,7 @@ import (
|
|||
"github.com/milvus-io/milvus/pkg/common"
|
||||
"github.com/milvus-io/milvus/pkg/log"
|
||||
"github.com/milvus-io/milvus/pkg/util/merr"
|
||||
"github.com/milvus-io/milvus/pkg/util/paramtable"
|
||||
)
|
||||
|
||||
// QueryHook is the interface for search/query parameter optimizer.
|
||||
|
@ -57,11 +58,12 @@ func OptimizeSearchParams(ctx context.Context, req *querypb.SearchRequest, query
|
|||
withFilter := (plan.GetVectorAnns().GetPredicates() != nil)
|
||||
queryInfo := plan.GetVectorAnns().GetQueryInfo()
|
||||
params := map[string]any{
|
||||
common.TopKKey: queryInfo.GetTopk(),
|
||||
common.SearchParamKey: queryInfo.GetSearchParams(),
|
||||
common.SegmentNumKey: estSegmentNum,
|
||||
common.WithFilterKey: withFilter,
|
||||
common.CollectionKey: req.GetReq().GetCollectionID(),
|
||||
common.TopKKey: queryInfo.GetTopk(),
|
||||
common.SearchParamKey: queryInfo.GetSearchParams(),
|
||||
common.SegmentNumKey: estSegmentNum,
|
||||
common.WithFilterKey: withFilter,
|
||||
common.WithOptimizeKey: paramtable.Get().AutoIndexConfig.EnableOptimize.GetAsBool(),
|
||||
common.CollectionKey: req.GetReq().GetCollectionID(),
|
||||
}
|
||||
err := queryHook.Run(params)
|
||||
if err != nil {
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
"github.com/milvus-io/milvus/internal/proto/querypb"
|
||||
"github.com/milvus-io/milvus/pkg/common"
|
||||
"github.com/milvus-io/milvus/pkg/util/merr"
|
||||
"github.com/milvus-io/milvus/pkg/util/paramtable"
|
||||
)
|
||||
|
||||
type QueryHookSuite struct {
|
||||
|
@ -30,6 +31,8 @@ func (suite *QueryHookSuite) TearDownTest() {
|
|||
func (suite *QueryHookSuite) TestOptimizeSearchParam() {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
paramtable.Init()
|
||||
paramtable.Get().Save(paramtable.Get().AutoIndexConfig.EnableOptimize.Key, "true")
|
||||
|
||||
suite.Run("normal_run", func() {
|
||||
mockHook := NewMockQueryHook(suite.T())
|
||||
|
|
|
@ -88,11 +88,12 @@ const (
|
|||
|
||||
// Search, Index parameter keys
|
||||
const (
|
||||
TopKKey = "topk"
|
||||
SearchParamKey = "search_param"
|
||||
SegmentNumKey = "segment_num"
|
||||
WithFilterKey = "with_filter"
|
||||
CollectionKey = "collection"
|
||||
TopKKey = "topk"
|
||||
SearchParamKey = "search_param"
|
||||
SegmentNumKey = "segment_num"
|
||||
WithFilterKey = "with_filter"
|
||||
WithOptimizeKey = "with_optimize"
|
||||
CollectionKey = "collection"
|
||||
|
||||
IndexParamsKey = "params"
|
||||
IndexTypeKey = "index_type"
|
||||
|
|
|
@ -28,7 +28,8 @@ import (
|
|||
// /////////////////////////////////////////////////////////////////////////////
|
||||
// --- common ---
|
||||
type autoIndexConfig struct {
|
||||
Enable ParamItem `refreshable:"true"`
|
||||
Enable ParamItem `refreshable:"true"`
|
||||
EnableOptimize ParamItem `refreshable:"true"`
|
||||
|
||||
IndexParams ParamItem `refreshable:"true"`
|
||||
PrepareParams ParamItem `refreshable:"true"`
|
||||
|
@ -48,6 +49,14 @@ func (p *autoIndexConfig) init(base *BaseTable) {
|
|||
}
|
||||
p.Enable.Init(base.mgr)
|
||||
|
||||
p.EnableOptimize = ParamItem{
|
||||
Key: "autoIndex.optimize",
|
||||
Version: "2.4.0",
|
||||
DefaultValue: "true",
|
||||
PanicIfEmpty: true,
|
||||
}
|
||||
p.EnableOptimize.Init(base.mgr)
|
||||
|
||||
p.IndexParams = ParamItem{
|
||||
Key: "autoIndex.params.build",
|
||||
Version: "2.2.0",
|
||||
|
|
Loading…
Reference in New Issue