Documentation ¶
Overview ¶
Package opensearch contains an implementation of the VectorStore interface that connects to Opensearch.
Index ¶
- Variables
- type IndexOption
- type Option
- type Store
- func (s Store) AddDocuments(ctx context.Context, docs []schema.Document, options ...vectorstores.Option) ([]string, error)
- func (s *Store) CreateIndex(ctx context.Context, indexName string, opts ...IndexOption) (*opensearchapi.Response, error)
- func (s *Store) DeleteIndex(ctx context.Context, indexName string) (*opensearchapi.Response, error)
- func (s Store) SimilaritySearch(ctx context.Context, query string, numDocuments int, ...) ([]schema.Document, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNumberOfVectorDoesNotMatch when providing documents, // the number of vectors generated should be equal to the number of docs. ErrNumberOfVectorDoesNotMatch = errors.New( "number of vectors from embedder does not match number of documents", ) // ErrAssertingMetadata Metadata is stored as string, trigger. ErrAssertingMetadata = errors.New( "couldn't assert metadata to map", ) )
var ( // ErrMissingEmbedded an embedder must be provided. ErrMissingEmbedded = errors.New( "missing embedder", ) // ErrMissingOpensearchClient an opensearch client must be provided. ErrMissingOpensearchClient = errors.New( "missing opensearch client", ) )
Functions ¶
This section is empty.
Types ¶
type IndexOption ¶
type IndexOption func(indexMap *map[string]interface{})
IndexOption for passing the schema of the index as option argument for custom modification.
type Option ¶
type Option func(p *Store)
Option is a function type that can be used to modify the client.
func WithEmbedder ¶
func WithEmbedder(e embeddings.Embedder) Option
WithEmbedder returns an Option for setting the embedder that could be used when adding documents or doing similarity search (instead the embedder from the Store context) this is useful when we are using multiple LLMs with single vectorstore.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a wrapper around the chromaGo API and client.
func New ¶
func New(client *opensearchgo.Client, opts ...Option) (Store, error)
New creates and returns a vectorstore object for Opensearch and returns the `Store` object needed by the other accessors.
func (Store) AddDocuments ¶
func (s Store) AddDocuments( ctx context.Context, docs []schema.Document, options ...vectorstores.Option, ) ([]string, error)
AddDocuments adds the text and metadata from the documents to the Chroma collection associated with 'Store'. and returns the ids of the added documents.
func (*Store) CreateIndex ¶
func (s *Store) CreateIndex( ctx context.Context, indexName string, opts ...IndexOption, ) (*opensearchapi.Response, error)
CreateIndex for creating an index before to add a document to it.
func (*Store) DeleteIndex ¶
func (s *Store) DeleteIndex( ctx context.Context, indexName string, ) (*opensearchapi.Response, error)
DeleteIndex for deleting an index before to add a document to it.
func (Store) SimilaritySearch ¶
func (s Store) SimilaritySearch( ctx context.Context, query string, numDocuments int, options ...vectorstores.Option, ) ([]schema.Document, error)
SimilaritySearch creates a vector embedding from the query using the embedder and queries to find the most similar documents.