Skip to content

Commit 451c232

Browse files
author
MrPresent-Han
committed
feat: support multi analyzer for restful(#41968)
Signed-off-by: MrPresent-Han <[email protected]>
1 parent 0e75e66 commit 451c232

File tree

3 files changed

+27
-11
lines changed

3 files changed

+27
-11
lines changed

internal/distributed/proxy/httpserver/handler_v2.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import (
4343
"github.com/milvus-io/milvus/internal/json"
4444
"github.com/milvus-io/milvus/internal/proxy"
4545
"github.com/milvus-io/milvus/internal/types"
46+
"github.com/milvus-io/milvus/internal/util/function"
4647
"github.com/milvus-io/milvus/internal/util/hookutil"
4748
"github.com/milvus-io/milvus/pkg/v2/common"
4849
"github.com/milvus-io/milvus/pkg/v2/log"
@@ -1522,6 +1523,20 @@ func (h *HandlersV2) createCollection(ctx context.Context, c *gin.Context, anyRe
15221523
if lo.Contains(allOutputFields, field.FieldName) {
15231524
fieldSchema.IsFunctionOutput = true
15241525
}
1526+
1527+
if field.MultiAnalyzerParam != nil {
1528+
multiAnalyzerBytes, err := json.Marshal(field.MultiAnalyzerParam)
1529+
if err != nil {
1530+
log.Ctx(ctx).Warn("parse MultiAnalyzer failed")
1531+
HTTPAbortReturn(c, http.StatusOK, gin.H{
1532+
HTTPReturnCode: merr.Code(err),
1533+
HTTPReturnMessage: "parse MultiAnalyzer failed, err:" + err.Error(),
1534+
})
1535+
return nil, err
1536+
}
1537+
multiAnalyzerStr := string(multiAnalyzerBytes)
1538+
fieldSchema.TypeParams = append(fieldSchema.TypeParams, &commonpb.KeyValuePair{Key: function.MultiAnalyzerParams, Value: multiAnalyzerStr})
1539+
}
15251540
collSchema.Fields = append(collSchema.Fields, &fieldSchema)
15261541
fieldNames[field.FieldName] = true
15271542
}

internal/distributed/proxy/httpserver/request_v2.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -468,15 +468,16 @@ func (req *DropIndexPropertiesReq) GetIndexName() string {
468468
}
469469

470470
type FieldSchema struct {
471-
FieldName string `json:"fieldName" binding:"required"`
472-
DataType string `json:"dataType" binding:"required"`
473-
ElementDataType string `json:"elementDataType"`
474-
IsPrimary bool `json:"isPrimary"`
475-
IsPartitionKey bool `json:"isPartitionKey"`
476-
IsClusteringKey bool `json:"isClusteringKey"`
477-
ElementTypeParams map[string]interface{} `json:"elementTypeParams" binding:"required"`
478-
Nullable bool `json:"nullable" binding:"required"`
479-
DefaultValue interface{} `json:"defaultValue" binding:"required"`
471+
FieldName string `json:"fieldName" binding:"required"`
472+
DataType string `json:"dataType" binding:"required"`
473+
ElementDataType string `json:"elementDataType"`
474+
IsPrimary bool `json:"isPrimary"`
475+
IsPartitionKey bool `json:"isPartitionKey"`
476+
IsClusteringKey bool `json:"isClusteringKey"`
477+
ElementTypeParams map[string]interface{} `json:"elementTypeParams" binding:"required"`
478+
Nullable bool `json:"nullable" binding:"required"`
479+
DefaultValue interface{} `json:"defaultValue" binding:"required"`
480+
MultiAnalyzerParam interface{} `json:"multiAnalyzerParam"`
480481
}
481482

482483
type FunctionSchema struct {

internal/util/function/multi_analyzer_bm25_function.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
"github.com/milvus-io/milvus/pkg/v2/util/typeutil"
3030
)
3131

32-
const multiAnalyzerParams = "multi_analyzer_params"
32+
const MultiAnalyzerParams = "multi_analyzer_params"
3333

3434
// BM25 Runner with Multi Analyzer
3535
// Input: string string // text, analyzer name
@@ -45,7 +45,7 @@ type MultiAnalyzerBM25FunctionRunner struct {
4545

4646
func getMultiAnalyzerParams(field *schemapb.FieldSchema) (string, bool) {
4747
for _, param := range field.GetTypeParams() {
48-
if param.Key == multiAnalyzerParams {
48+
if param.Key == MultiAnalyzerParams {
4949
return param.Value, true
5050
}
5151
}

0 commit comments

Comments
 (0)