Skip to content

Commit

Permalink
fix: redis query categories use escape (#770)
Browse files Browse the repository at this point in the history
Co-authored-by: cc <cc@xinpianchang.com>
  • Loading branch information
imlewc and cc committed Sep 5, 2023
1 parent 5f12697 commit 24d69b1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion storage/cache/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func (r *Redis) SearchDocuments(ctx context.Context, collection, subset string,
builder.WriteString(fmt.Sprintf(" @subset:{ %s }", escape(subset)))
}
for _, q := range query {
builder.WriteString(fmt.Sprintf(" @categories:{ %s }", encdodeCategory(q)))
builder.WriteString(fmt.Sprintf(" @categories:{ %s }", escape(encdodeCategory(q))))
}
args := []any{"FT.SEARCH", r.DocumentTable(), builder.String(), "SORTBY", "score", "DESC", "LIMIT", begin}
if end == -1 {
Expand Down Expand Up @@ -560,6 +560,7 @@ func escape(s string) string {
":", "\\:",
".", "\\.",
"/", "\\/",
"+", "\\+",
)
return r.Replace(s)
}

0 comments on commit 24d69b1

Please sign in to comment.