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:
aoiasd 2025-08-20 10:59:46 +08:00 committed by GitHub
parent d6a428e880
commit 8d49ffcc8b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 5 deletions

View File

@ -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

View File

@ -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{