Skip to content

Commit

Permalink
MB-61889: support search with params
Browse files Browse the repository at this point in the history
  • Loading branch information
moshaad7 committed Jul 8, 2024
1 parent bdc70e4 commit e979d30
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions faiss_vector_posting.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package zap

import (
"encoding/binary"
"encoding/json"
"math"
"reflect"

Expand Down Expand Up @@ -266,14 +267,14 @@ func (vpl *VecPostingsIterator) BytesWritten() uint64 {

// vectorIndexWrapper conforms to scorch_segment_api's VectorIndex interface
type vectorIndexWrapper struct {
search func(qVector []float32, k int64) (segment.VecPostingsList, error)
search func(qVector []float32, k int64, params json.RawMessage) (segment.VecPostingsList, error)
close func()
size func() uint64
}

func (i *vectorIndexWrapper) Search(qVector []float32, k int64) (
func (i *vectorIndexWrapper) Search(qVector []float32, k int64, params json.RawMessage) (
segment.VecPostingsList, error) {
return i.search(qVector, k)
return i.search(qVector, k, params)
}

func (i *vectorIndexWrapper) Close() {
Expand All @@ -300,7 +301,7 @@ func (sb *SegmentBase) InterpretVectorIndex(field string, except *roaring.Bitmap

var (
wrapVecIndex = &vectorIndexWrapper{
search: func(qVector []float32, k int64) (segment.VecPostingsList, error) {
search: func(qVector []float32, k int64, params json.RawMessage) (segment.VecPostingsList, error) {
// 1. returned postings list (of type PostingsList) has two types of information - docNum and its score.
// 2. both the values can be represented using roaring bitmaps.
// 3. the Iterator (of type PostingsIterator) returned would operate in terms of VecPostings.
Expand All @@ -317,7 +318,7 @@ func (sb *SegmentBase) InterpretVectorIndex(field string, except *roaring.Bitmap
return rv, nil
}

scores, ids, err := vecIndex.SearchWithoutIDs(qVector, k, vectorIDsToExclude)
scores, ids, err := vecIndex.SearchWithoutIDs(qVector, k, vectorIDsToExclude, params)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit e979d30

Please sign in to comment.