Skip to content

Commit

Permalink
Refactor MaxKValue to BleveMaxK, also make it a global "var" (#1954)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinavdangeti authored Jan 5, 2024
1 parent 58e76ce commit b37cb2b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions search_knn.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ import (

type knnOperator string

const MaxKValue = 10000
// Must be updated only at init
var BleveMaxK = int64(10000)

type SearchRequest struct {
Query query.Query `json:"query"`
Expand Down Expand Up @@ -232,8 +233,8 @@ func validateKNN(req *SearchRequest) error {
if q.K <= 0 || len(q.Vector) == 0 {
return fmt.Errorf("k must be greater than 0 and vector must be non-empty")
}
if q.K > MaxKValue {
return fmt.Errorf("k must be less than %d", MaxKValue)
if q.K > BleveMaxK {
return fmt.Errorf("k must be less than %d", BleveMaxK)
}
}
switch req.KNNOperator {
Expand Down

0 comments on commit b37cb2b

Please sign in to comment.