Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix nResults validation
  • Loading branch information
philippgille committed Mar 17, 2024
commit a8b7e80e6aa839d425fa5e1a2e0539b5eeef5948
4 changes: 2 additions & 2 deletions collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ func (c *Collection) Query(ctx context.Context, queryText string, nResults int,
}
c.documentsLock.RLock()
defer c.documentsLock.RUnlock()
if nResults < len(c.documents) {
return nil, errors.New("nResults must be greater than the number of documents in the collection")
if nResults > len(c.documents) {
return nil, errors.New("nResults must be <= the number of documents in the collection")
}

if len(c.documents) == 0 {
Expand Down