mirror of https://github.com/milvus-io/milvus.git
related: #29968 Signed-off-by: MrPresent-Han <chun.han@zilliz.com>pull/31829/head
parent
91cb529ba6
commit
92c84ccc3f
|
@ -21,7 +21,7 @@ import (
|
|||
"github.com/milvus-io/milvus/pkg/util/typeutil"
|
||||
)
|
||||
|
||||
func initSearchRequest(ctx context.Context, t *searchTask) error {
|
||||
func initSearchRequest(ctx context.Context, t *searchTask, isHybrid bool) error {
|
||||
ctx, sp := otel.Tracer(typeutil.ProxyRole).Start(ctx, "init search request")
|
||||
defer sp.End()
|
||||
|
||||
|
@ -78,6 +78,9 @@ func initSearchRequest(ctx context.Context, t *searchTask) error {
|
|||
}
|
||||
queryInfo, offset, err := parseSearchInfo(t.request.GetSearchParams(), t.schema.CollectionSchema)
|
||||
annField := typeutil.GetFieldByName(t.schema.CollectionSchema, annsFieldName)
|
||||
if queryInfo.GetGroupByFieldId() != -1 && isHybrid {
|
||||
return errors.New("not support search_group_by operation in the hybrid search")
|
||||
}
|
||||
if queryInfo.GetGroupByFieldId() != -1 && annField.GetDataType() == schemapb.DataType_BinaryVector {
|
||||
return errors.New("not support search_group_by operation based on binary vector column")
|
||||
}
|
||||
|
|
|
@ -211,7 +211,7 @@ func (t *hybridSearchTask) PreExecute(ctx context.Context) error {
|
|||
partitionKeyMode: t.partitionKeyMode,
|
||||
resultBuf: typeutil.NewConcurrentSet[*internalpb.SearchResults](),
|
||||
}
|
||||
err := initSearchRequest(ctx, t.searchTasks[index])
|
||||
err := initSearchRequest(ctx, t.searchTasks[index], true)
|
||||
if err != nil {
|
||||
log.Debug("init hybrid search request failed", zap.Error(err))
|
||||
return err
|
||||
|
|
|
@ -136,6 +136,28 @@ func TestHybridSearchTask_PreExecute(t *testing.T) {
|
|||
task.request.OutputFields = []string{testFloatVecField}
|
||||
assert.NoError(t, task.PreExecute(ctx))
|
||||
})
|
||||
|
||||
t.Run("hybrid search with group_by", func(t *testing.T) {
|
||||
collName := "hybrid_search_with_group_by" + funcutil.GenRandomStr()
|
||||
createCollWithMultiVecField(t, collName, rc)
|
||||
|
||||
task := genHybridSearchTaskWithNq(t, collName, []*milvuspb.SearchRequest{
|
||||
{Nq: 1, DslType: commonpb.DslType_BoolExprV1, SearchParams: []*commonpb.KeyValuePair{
|
||||
{Key: AnnsFieldKey, Value: "fvec"},
|
||||
{Key: TopKKey, Value: "10"},
|
||||
{Key: GroupByFieldKey, Value: "bool"},
|
||||
}},
|
||||
})
|
||||
|
||||
ctxTimeout, cancel := context.WithTimeout(ctx, time.Second)
|
||||
defer cancel()
|
||||
|
||||
task.ctx = ctxTimeout
|
||||
task.request.OutputFields = []string{testFloatVecField}
|
||||
err := task.PreExecute(ctx)
|
||||
assert.Error(t, err)
|
||||
assert.Equal(t, "not support search_group_by operation in the hybrid search", err.Error())
|
||||
})
|
||||
}
|
||||
|
||||
func TestHybridSearchTask_ErrExecute(t *testing.T) {
|
||||
|
|
|
@ -337,7 +337,7 @@ func (t *searchTask) PreExecute(ctx context.Context) error {
|
|||
log.Debug("translate output fields",
|
||||
zap.Strings("output fields", t.request.GetOutputFields()))
|
||||
|
||||
err = initSearchRequest(ctx, t)
|
||||
err = initSearchRequest(ctx, t, false)
|
||||
if err != nil {
|
||||
log.Debug("init search request failed", zap.Error(err))
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue