Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
implement exact search for emotes
Browse files Browse the repository at this point in the history
  • Loading branch information
broadeditz committed Dec 3, 2023
1 parent 2a4ae35 commit 0181188
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions data/query/query.search-emotes.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ func (q *Query) SearchEmotes(ctx context.Context, opt SearchEmotesOptions) ([]st
req.Page = 1
}

if opt.Filter != nil {
if opt.Filter.ExactMatch != nil {
req.Exact = *opt.Filter.ExactMatch
}
}

// Define default filter
//filter := opt.Filter
//if filter == nil {
Expand Down
5 changes: 5 additions & 0 deletions internal/search/emote.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type EmoteSearchOptions struct {
Limit int64
Page int64
Sort EmoteSortOptions
Exact bool
Personal bool
Listed bool
Lifecycle int32
Expand Down Expand Up @@ -59,6 +60,10 @@ func (s *MeiliSearch) SearchEmotes(query string, opt EmoteSearchOptions) ([]Emot
req.Filter = filter
}

if opt.Exact {
query = "\"" + query + "\""
}

res, err := s.emoteIndex.Search(query, req)

if err != nil {
Expand Down

0 comments on commit 0181188

Please sign in to comment.