diff --git a/raiju.go b/raiju.go index 3097735..9ca8114 100644 --- a/raiju.go +++ b/raiju.go @@ -247,12 +247,11 @@ func (r Raiju) Candidates(ctx context.Context, request CandidatesRequest) ([]Rel sort.Sort(sort.Reverse(sortDistance(allCandidates))) - if int64(len(allCandidates)) < request.Limit { - return allCandidates, nil + candidates := allCandidates + if int64(len(allCandidates)) >= request.Limit { + candidates = allCandidates[:request.Limit] } - candidates := allCandidates[:request.Limit] - printNodes(candidates) return candidates, nil