Skip to content

Commit

Permalink
fix for json parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
metonymic-smokey committed Sep 13, 2024
1 parent 5a9c121 commit f59776f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions search_knn.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ type KNNRequest struct {

// Filter query to use with kNN pre-filtering.
// Supports pre-filtering with all existing types of query clauses.
FilterQuery query.Query `JSON:"filter,omitempty"`
FilterQuery interface{} `JSON:"filter,omitempty"`
}

func (r *SearchRequest) AddKNN(field string, vector []float32, k int64, boost float64) {
Expand All @@ -104,7 +104,7 @@ func (r *SearchRequest) AddKNN(field string, vector []float32, k int64, boost fl
}

func (r *SearchRequest) AddKNNWithFilter(field string, vector []float32, k int64,
boost float64, filterQuery query.Query) {
boost float64, filterQuery interface{}) {
b := query.Boost(boost)
r.KNN = append(r.KNN, &KNNRequest{
Field: field,
Expand Down Expand Up @@ -275,7 +275,7 @@ func createKNNQuery(req *SearchRequest, eligibleDocsMap map[int][]index.IndexInt
knnQuery.SetBoost(knn.Boost.Value())
knnQuery.SetParams(knn.Params)
if len(eligibleDocsMap[i]) > 0 {
knnQuery.SetFilterQuery(knn.FilterQuery)
knnQuery.SetFilterQuery(knn.FilterQuery.(query.Query))
filterResults, exists := eligibleDocsMap[i]
if exists {
knnQuery.SetFilterResults(filterResults)
Expand Down Expand Up @@ -389,7 +389,7 @@ func (i *indexImpl) runKnnCollector(ctx context.Context, req *SearchRequest, rea
}

// Applies to all supported types of queries.
filterSearcher, _ := filterQ.Searcher(ctx, reader, i.m, search.SearcherOptions{
filterSearcher, _ := filterQ.(query.Query).Searcher(ctx, reader, i.m, search.SearcherOptions{
Score: "none", // just want eligible hits --> don't compute scores if not needed
})
// Using the index doc count to determine collector size since we do not
Expand Down

0 comments on commit f59776f

Please sign in to comment.