Skip to content

Commit

Permalink
Fixed UT
Browse files Browse the repository at this point in the history
  • Loading branch information
metonymic-smokey committed Nov 21, 2023
1 parent 674b827 commit dc9ec92
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions search_knn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ import (
"github.com/blevesearch/bleve/v2/search/query"
)

func getRandomQueryVec(dims int) []float32 {
vec := make([]float32, dims)
for i := 0; i < dims; i++ {
vec[i] = rand.Float32()
}
return vec
}

// Test to see if KNN Operators get added right to the query.
func TestKNNOperator(t *testing.T) {
tmpIndexPath := createTmpIndexPath(t)
Expand Down Expand Up @@ -86,10 +94,10 @@ func TestKNNOperator(t *testing.T) {
log.Fatal(err)
}

termQuery := query.NewTermQuery("world")
termQuery := query.NewTermQuery("2")

searchRequest := NewSearchRequest(termQuery)
queryVec2 := getQueryVec("hilly region worldwide")
queryVec2 := getRandomQueryVec(5)
searchRequest.AddKNN("vector", queryVec2, 3, 2.0)
searchRequest.AddKNN("vector", queryVec2, 2, 1.5)
searchRequest.Fields = []string{"content", "vector"}
Expand Down

0 comments on commit dc9ec92

Please sign in to comment.