mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
enhance: report field name when text match or pharse match failed because field not enable match (#43366)
relate: https://github.com/milvus-io/milvus/issues/41953 Signed-off-by: aoiasd <zhicheng.yue@zilliz.com>
This commit is contained in:
parent
d6a428e880
commit
8d49ffcc8b
@ -500,20 +500,21 @@ func (v *ParserVisitor) VisitLike(ctx *parser.LikeContext) interface{} {
|
||||
}
|
||||
|
||||
func (v *ParserVisitor) VisitTextMatch(ctx *parser.TextMatchContext) interface{} {
|
||||
column, err := v.translateIdentifier(ctx.Identifier().GetText())
|
||||
identifier := ctx.Identifier().GetText()
|
||||
column, err := v.translateIdentifier(identifier)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
columnInfo := toColumnInfo(column)
|
||||
if !v.schema.IsFieldTextMatchEnabled(columnInfo.FieldId) {
|
||||
return fmt.Errorf("field %v does not enable text match", columnInfo.FieldId)
|
||||
}
|
||||
if !typeutil.IsStringType(column.dataType) {
|
||||
return errors.New("text match operation on non-string is unsupported")
|
||||
}
|
||||
if column.dataType == schemapb.DataType_Text {
|
||||
return errors.New("text match operation on text field is not supported yet")
|
||||
}
|
||||
if !v.schema.IsFieldTextMatchEnabled(columnInfo.FieldId) {
|
||||
return fmt.Errorf("field \"%s\" does not enable match", identifier)
|
||||
}
|
||||
|
||||
queryText, err := convertEscapeSingle(ctx.StringLiteral().GetText())
|
||||
if err != nil {
|
||||
@ -535,13 +536,20 @@ func (v *ParserVisitor) VisitTextMatch(ctx *parser.TextMatchContext) interface{}
|
||||
}
|
||||
|
||||
func (v *ParserVisitor) VisitPhraseMatch(ctx *parser.PhraseMatchContext) interface{} {
|
||||
column, err := v.translateIdentifier(ctx.Identifier().GetText())
|
||||
identifier := ctx.Identifier().GetText()
|
||||
column, err := v.translateIdentifier(identifier)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
columnInfo := toColumnInfo(column)
|
||||
if !typeutil.IsStringType(column.dataType) {
|
||||
return errors.New("phrase match operation on non-string is unsupported")
|
||||
}
|
||||
if !v.schema.IsFieldTextMatchEnabled(columnInfo.FieldId) {
|
||||
return fmt.Errorf("field \"%s\" does not enable match", identifier)
|
||||
}
|
||||
|
||||
queryText, err := convertEscapeSingle(ctx.StringLiteral().GetText())
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@ -294,6 +294,7 @@ func TestExpr_TextMatch(t *testing.T) {
|
||||
func TestExpr_PhraseMatch(t *testing.T) {
|
||||
schema := newTestSchema(true)
|
||||
helper, err := typeutil.CreateSchemaHelper(schema)
|
||||
enableMatch(schema)
|
||||
assert.NoError(t, err)
|
||||
|
||||
exprStrs := []string{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user