Documentation
¶
Index ¶
Constants ¶
View Source
const ( SequentialManifestType = "sequential" HnswManifestType = "hnsw" )
Variables ¶
View Source
var ( ErrInvalidVectorIndexType = fmt.Errorf("invalid vector index type") ErrInvalidVectorIndexName = fmt.Errorf("invalid vector index name") )
Functions ¶
This section is empty.
Types ¶
type CollectionNamespace ¶
type CollectionNamespace interface {
GetCollectionName() string
GetNamespace() string
// GetVectorIndexMap returns the map of searchMethod to VectorIndex
GetVectorIndexMap() map[string]*VectorIndexWrapper
// GetVectorIndex returns the VectorIndex for a given searchMethod
GetVectorIndex(ctx context.Context, searchMethod string) (*VectorIndexWrapper, error)
// SetVectorIndex sets the VectorIndex for a given searchMethod
SetVectorIndex(ctx context.Context, searchMethod string, index *VectorIndexWrapper) error
// DeleteVectorIndex deletes the VectorIndex for a given searchMethod
DeleteVectorIndex(ctx context.Context, searchMethod string) error
// InsertTexts will add texts and keys into the existing VectorIndex
InsertTexts(ctx context.Context, keys []string, texts []string, labelsArr [][]string) error
// InsertText will add a text and key into the existing VectorIndex
InsertText(ctx context.Context, key string, text string, labels []string) error
InsertTextsToMemory(ctx context.Context, ids []int64, keys []string, texts []string, labelsArr [][]string) error
InsertTextToMemory(ctx context.Context, id int64, key string, text string, labels []string) error
// DeleteText will remove a text and key from the existing VectorIndex
DeleteText(ctx context.Context, key string) error
// GetText will return the text for a given key
GetText(ctx context.Context, key string) (string, error)
// GetLabel will return the label for a given key
GetLabels(ctx context.Context, key string) ([]string, error)
// GetTextMap returns the map of key to text
GetTextMap(ctx context.Context) (map[string]string, error)
// GetLabelMap returns the map of key to label
GetLabelsMap(ctx context.Context) (map[string][]string, error)
//Len returns the number of texts in the collection
Len(ctx context.Context) (int, error)
// GetExternalId returns the external id for a given key
GetExternalId(ctx context.Context, key string) (int64, error)
GetCheckpointId(ctx context.Context) (int64, error)
}
type UnmarshalSequentialVectorIndex ¶
type UnmarshalSequentialVectorIndex struct {
VectorIndex sequential.SequentialVectorIndex `json:"VectorIndex"`
}
type VectorIndex ¶
type VectorIndex interface {
GetSearchMethodName() string
SetEmbedderName(embedderName string) error
GetEmbedderName() string
// Search will find the keys for a given set of vectors based on the
// input query, limiting to the specified maximum number of results.
// The filter parameter indicates that we might discard certain parameters
// based on some input criteria. The maxResults count is counted *after*
// being filtered. In other words, we only count those results that had not
// been filtered out.
Search(ctx context.Context, query []float32,
maxResults int,
filter index.SearchFilter) (utils.MaxTupleHeap, error)
// SearchWithKey will find the keys for a given set of vectors based on the
// input queryKey, limiting to the specified maximum number of results.
// The filter parameter indicates that we might discard certain parameters
// based on some input criteria. The maxResults count is counted *after*
// being filtered. In other words, we only count those results that had not
// been filtered out.
SearchWithKey(ctx context.Context, queryKey string,
maxResults int,
filter index.SearchFilter) (utils.MaxTupleHeap, error)
// Insert Vectors will add vectors and keys into the existing VectorIndex
InsertVectors(ctx context.Context, textIds []int64, vecs [][]float32) error
// Insert will add a vector and key into the existing VectorIndex. If
// key already exists, it should throw an error to not insert duplicate keys
InsertVector(ctx context.Context, textId int64, vec []float32) error
// InsertVectorsToMemory will add vectors and keys into the existing VectorIndex
InsertVectorsToMemory(ctx context.Context, textIds []int64, vectorIds []int64, keys []string, vecs [][]float32) error
// InsertVectorToMemory will add a vector and key into the existing VectorIndex. If
// key already exists, it should throw an error to not insert duplicate keys
InsertVectorToMemory(ctx context.Context, textId, vectorId int64, key string, vec []float32) error
// Delete will remove a vector and key from the existing VectorIndex. If
// key does not exist, it should throw an error to not delete non-existent keys
DeleteVector(ctx context.Context, textId int64, key string) error
// GetVector will return the vector for a given key
GetVector(ctx context.Context, key string) ([]float32, error)
GetCheckpointId(ctx context.Context) (int64, error)
GetLastIndexedTextId(ctx context.Context) (int64, error)
}
A VectorIndex can be used to Search for vectors and add vectors to an index.
type VectorIndexWrapper ¶
type VectorIndexWrapper struct {
Type string `json:"Type"`
VectorIndex
}
func (*VectorIndexWrapper) UnmarshalJSON ¶
func (v *VectorIndexWrapper) UnmarshalJSON(data []byte) error
Click to show internal directories.
Click to hide internal directories.