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

Commit 4343e08

Browse files
authored
[all sample] Fix Elastic's .keyword, .text (#1321)
It's probably not the perfect solution, as e.g. we might enable search on some type of column which will be slow. It's not a huge issue for now though, I guess. Before: <img width="855" alt="Screenshot 2025-03-02 at 16 28 39" src="https://github.com/user-attachments/assets/744398b9-730f-48ee-a4e4-8a3524710804" /> After: <img width="871" alt="Screenshot 2025-03-02 at 16 29 39" src="https://github.com/user-attachments/assets/dc270207-b536-45cb-ac1a-a470cba996e1" />
1 parent 3f39643 commit 4343e08

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

platform/functionality/field_capabilities/field_caps.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,8 @@ func handleFieldCapsIndex(cfg map[string]config.IndexConfiguration, schemaRegist
7070
for fieldName, field := range fieldsWithAliases {
7171
addFieldCapabilityFromSchemaRegistry(fields, fieldName.AsString(), field.Type, resolvedIndex)
7272
switch field.Type.Name {
73-
case "text":
73+
case "keyword", "text":
7474
addFieldCapabilityFromSchemaRegistry(fields, fmt.Sprintf("%s%s", fieldName.AsString(), types.MultifieldKeywordSuffix), schema.QuesmaTypeKeyword, resolvedIndex)
75-
case "keyword":
7675
addFieldCapabilityFromSchemaRegistry(fields, fmt.Sprintf("%s%s", fieldName.AsString(), types.MultifieldTextSuffix), schema.QuesmaTypeText, resolvedIndex)
7776
case "map":
7877
addFieldCapabilityFromSchemaRegistry(fields, fmt.Sprintf("%s%s", fieldName.AsString(), types.MultifieldTextSuffix), schema.QuesmaTypeText, resolvedIndex)

platform/functionality/field_capabilities/field_caps_test.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ func TestFieldCaps(t *testing.T) {
2424
"metadata_field": false,
2525
"indices": ["logs-generic-default"]
2626
}
27+
},
28+
"arrayOfArraysOfStrings.keyword": {
29+
"keyword": {
30+
"aggregatable": true,
31+
"searchable": true,
32+
"type": "keyword",
33+
"metadata_field": false,
34+
"indices": ["logs-generic-default"]
35+
}
2736
},
2837
"arrayOfArraysOfStrings.text": {
2938
"text": {
@@ -53,6 +62,15 @@ func TestFieldCaps(t *testing.T) {
5362
}
5463
},
5564
"service.name": {
65+
"keyword": {
66+
"aggregatable": true,
67+
"searchable": true,
68+
"metadata_field": false,
69+
"type": "keyword",
70+
"indices": ["logs-generic-default"]
71+
}
72+
},
73+
"service.name.keyword": {
5674
"keyword": {
5775
"aggregatable": true,
5876
"searchable": true,
@@ -214,6 +232,15 @@ func TestFieldCapsMultipleIndexes(t *testing.T) {
214232
"type": "keyword",
215233
"indices": ["logs-1"]
216234
}
235+
},
236+
"foo.bar1.keyword": {
237+
"keyword": {
238+
"aggregatable": true,
239+
"searchable": true,
240+
"metadata_field": false,
241+
"type": "keyword",
242+
"indices": ["logs-1"]
243+
}
217244
},
218245
"foo.bar1.text": {
219246
"text": {
@@ -234,6 +261,15 @@ func TestFieldCapsMultipleIndexes(t *testing.T) {
234261
"type": "keyword",
235262
"indices": ["logs-2"]
236263
}
264+
},
265+
"foo.bar2.keyword": {
266+
"keyword": {
267+
"aggregatable": true,
268+
"searchable": true,
269+
"metadata_field": false,
270+
"type": "keyword",
271+
"indices": ["logs-2"]
272+
}
237273
},
238274
"foo.bar2.text": {
239275
"text": {
@@ -338,6 +374,15 @@ func TestFieldCapsMultipleIndexesConflictingEntries(t *testing.T) {
338374
"type": "boolean",
339375
"indices": ["logs-2", "logs-3"]
340376
}
377+
},
378+
"foo.bar.keyword": {
379+
"keyword": {
380+
"aggregatable": false,
381+
"searchable": true,
382+
"metadata_field": false,
383+
"type": "keyword",
384+
"indices": ["logs-1"]
385+
}
341386
},
342387
"foo.bar.text": {
343388
"text": {

0 commit comments

Comments
 (0)