mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-08 01:58:34 +08:00
issue: #35528 pr: #40407 this pr includes some json index related pr: 1. #40407 2. #40538 3. #40419 --------- Signed-off-by: sunby <sunbingyi1992@gmail.com>
40 lines
1.2 KiB
Go
40 lines
1.2 KiB
Go
package indexparamcheck
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/milvus-io/milvus-proto/go-api/v2/schemapb"
|
|
"github.com/milvus-io/milvus/pkg/v2/common"
|
|
"github.com/milvus-io/milvus/pkg/v2/util/merr"
|
|
"github.com/milvus-io/milvus/pkg/v2/util/typeutil"
|
|
)
|
|
|
|
// INVERTEDChecker checks if a INVERTED index can be built.
|
|
type INVERTEDChecker struct {
|
|
scalarIndexChecker
|
|
}
|
|
|
|
func (c *INVERTEDChecker) CheckTrain(dataType schemapb.DataType, params map[string]string) error {
|
|
// check json index params
|
|
isJSONIndex := typeutil.IsJSONType(dataType)
|
|
if isJSONIndex {
|
|
if _, exist := params[common.JSONCastTypeKey]; !exist {
|
|
return merr.WrapErrParameterMissing(common.JSONCastTypeKey, "json index must specify cast type")
|
|
}
|
|
}
|
|
return c.scalarIndexChecker.CheckTrain(dataType, params)
|
|
}
|
|
|
|
func (c *INVERTEDChecker) CheckValidDataType(indexType IndexType, field *schemapb.FieldSchema) error {
|
|
dType := field.GetDataType()
|
|
if !typeutil.IsBoolType(dType) && !typeutil.IsArithmetic(dType) && !typeutil.IsStringType(dType) &&
|
|
!typeutil.IsArrayType(dType) && !typeutil.IsJSONType(dType) {
|
|
return fmt.Errorf("INVERTED are not supported on %s field", dType.String())
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func newINVERTEDChecker() *INVERTEDChecker {
|
|
return &INVERTEDChecker{}
|
|
}
|