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

Commit 6f208ac

Browse files
trzysiektrzysiek
andauthored
Add highlighing for Array(String) (#1306)
Works for arrays + we used to have regression because of omission of `ILIKE` there, but I think it fixed itself, after we recently started using `MatchOperator` more often instead. Before: ![Screenshot 2025-03-10 at 16 13 51](https://github.com/user-attachments/assets/fe46af0d-f688-429a-93f9-8a89bed422d9) After: ![Screenshot 2025-03-10 at 16 10 45](https://github.com/user-attachments/assets/8847f8c0-80b9-4b03-ad79-242e84e2c503) --------- Co-authored-by: trzysiek <[email protected]>
1 parent 0b1a835 commit 6f208ac

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

platform/model/highlighter.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,9 @@ func (h *Highlighter) SetTokensToHighlight(selectCmd SelectCommand) {
5454
h.Tokens = make(map[string]Tokens)
5555

5656
visitor := NewBaseVisitor()
57-
5857
visitor.OverrideVisitInfix = func(b *BaseExprVisitor, e InfixExpr) interface{} {
5958
switch e.Op {
60-
case "iLIKE", "LIKE", "IN", "=", MatchOperator:
59+
case "iLIKE", "ILIKE", "LIKE", "IN", "=", MatchOperator:
6160
lhs, isColumnRef := e.Left.(ColumnRef)
6261
rhs, isLiteral := e.Right.(LiteralExpr)
6362
if isLiteral && isColumnRef { // we only highlight in this case

platform/model/typical_queries/hits.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,16 @@ func (query Hits) addAndHighlightHit(hit *model.SearchHit, resultRow *model.Quer
157157
if valueAsString != nil {
158158
hit.Highlight[columnName] = query.highlighter.HighlightValue(util.FieldToColumnEncoder(columnName), *valueAsString)
159159
}
160+
case []string:
161+
for _, v := range valueAsString {
162+
hit.Highlight[columnName] = append(hit.Highlight[columnName], query.highlighter.HighlightValue(util.FieldToColumnEncoder(columnName), v)...)
163+
}
164+
case []*string:
165+
for _, v := range valueAsString {
166+
if v != nil {
167+
hit.Highlight[columnName] = append(hit.Highlight[columnName], query.highlighter.HighlightValue(util.FieldToColumnEncoder(columnName), *v)...)
168+
}
169+
}
160170
default:
161171
logger.WarnWithCtx(query.ctx).Msgf("unknown type for hit highlighting: %T, value: %v", col.Value, col.Value)
162172
}

0 commit comments

Comments
 (0)