Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

Commit a33da89

Browse files
committed
Extract common part
1 parent 7ae9d89 commit a33da89

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

platform/frontend_connectors/search_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ var ctx = context.WithValue(context.TODO(), tracing.RequestIdCtxKey, tracing.Get
4343

4444
func TestAsyncSearchHandler(t *testing.T) {
4545
// logger.InitSimpleLoggerForTests()
46+
4647
table := util.NewSyncMapWith(tableName, &clickhouse.Table{
4748
Name: tableName,
4849
Config: clickhouse.NewDefaultCHConfig(),

platform/parsers/elastic_query_dsl/query_parser.go

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,26 +1206,24 @@ func ResolveField(ctx context.Context, fieldName string, schemaInstance schema.S
12061206
fieldName = strings.TrimSuffix(fieldName, ".keyword")
12071207
fieldName = strings.TrimSuffix(fieldName, ".text")
12081208

1209+
updateQuesmaType := func(fieldKey schema.FieldName) {
1210+
field := schemaInstance.Fields[fieldKey]
1211+
field.Type = schema.QuesmaTypeKeyword
1212+
schemaInstance.Fields[field.PropertyName] = field
1213+
}
1214+
12091215
if resolvedField, ok := schemaInstance.ResolveField(fieldName); ok {
1210-
if isKeyword {
1211-
fieldKey := schema.FieldName(fieldName)
1212-
field := schemaInstance.Fields[fieldKey]
1213-
field.Type = schema.QuesmaTypeKeyword
1214-
if schemaInstance.Fields != nil {
1215-
schemaInstance.Fields[field.PropertyName] = field
1216-
}
1216+
if isKeyword && schemaInstance.Fields != nil {
1217+
updateQuesmaType(schema.FieldName(fieldName))
12171218
}
12181219
return resolvedField.InternalPropertyName.AsString()
12191220
} else {
12201221
if fieldName != "*" && fieldName != "_all" && fieldName != "_doc" && fieldName != "_id" && fieldName != "_index" {
12211222
logger.DebugWithCtx(ctx).Msgf("field '%s' referenced, but not found in schema, falling back to original name", fieldName)
12221223
}
1223-
if isKeyword {
1224-
fieldKey, _ := schemaInstance.ResolveFieldByInternalName(fieldName)
1225-
field := schemaInstance.Fields[fieldKey.PropertyName]
1226-
field.Type = schema.QuesmaTypeKeyword
1227-
if schemaInstance.Fields != nil {
1228-
schemaInstance.Fields[field.PropertyName] = field
1224+
if isKeyword && schemaInstance.Fields != nil {
1225+
if fieldKey, exists := schemaInstance.ResolveFieldByInternalName(fieldName); exists {
1226+
updateQuesmaType(fieldKey.PropertyName)
12291227
}
12301228
}
12311229
return fieldName

0 commit comments

Comments
 (0)