opensearch

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// URL is the OpenSearch endpoint (e.g., "http://localhost:9200")
	URL string

	// IndexName is the name of the index to use for chunks
	IndexName string

	// Timeout for requests
	Timeout time.Duration

	// InsecureSkipVerify disables TLS certificate verification (development only)
	InsecureSkipVerify bool
}

Config holds OpenSearch connection configuration

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a configuration with sensible defaults

type SearchEngine

type SearchEngine struct {
	// contains filtered or unexported fields
}

SearchEngine implements the driven.SearchEngine port using OpenSearch

func NewSearchEngine

func NewSearchEngine(cfg Config) (*SearchEngine, error)

NewSearchEngine creates a new OpenSearch search engine adapter

func (*SearchEngine) Count

func (s *SearchEngine) Count(ctx context.Context) (int64, error)

Count returns the total number of indexed chunks

func (*SearchEngine) Delete

func (s *SearchEngine) Delete(ctx context.Context, chunkIDs []string) error

Delete deletes chunks by IDs

func (*SearchEngine) DeleteByDocument

func (s *SearchEngine) DeleteByDocument(ctx context.Context, documentID string) error

DeleteByDocument deletes all chunks for a document

func (*SearchEngine) DeleteByDocuments

func (s *SearchEngine) DeleteByDocuments(ctx context.Context, documentIDs []string) error

DeleteByDocuments deletes all chunks for multiple documents in a single operation

func (*SearchEngine) DeleteBySource

func (s *SearchEngine) DeleteBySource(ctx context.Context, sourceID string) error

DeleteBySource deletes all chunks for a source

func (*SearchEngine) DeleteBySourceAndContainer added in v0.2.1

func (s *SearchEngine) DeleteBySourceAndContainer(ctx context.Context, sourceID, containerID string) error

DeleteBySourceAndContainer deletes all indexed data for a specific container within a source IMPLEMENTATION NOTE: Since container_id is not indexed in OpenSearch (chunks/documents only have source_id and document_id fields), we cannot filter directly by container_id. This is a limitation of the current schema - container_id lives in PostgreSQL document metadata only.

For a proper implementation, the service layer should: 1. Query PostgreSQL for document IDs matching (source_id, container_id) 2. Call DeleteByDocuments() with those document IDs

For now, this is a no-op placeholder. The service layer (deleteContainerData in source.go) will need to orchestrate the deletion by first querying document IDs, then calling DeleteByDocuments instead of this method.

func (*SearchEngine) GetDocument added in v0.2.1

func (s *SearchEngine) GetDocument(ctx context.Context, documentID string) (*domain.DocumentContent, error)

GetDocument retrieves a document by its document ID

func (*SearchEngine) HealthCheck

func (s *SearchEngine) HealthCheck(ctx context.Context) error

HealthCheck verifies the search engine is available

func (*SearchEngine) Index

func (s *SearchEngine) Index(ctx context.Context, chunks []*domain.Chunk) error

Index indexes chunks for searching

func (*SearchEngine) IndexDocument

func (s *SearchEngine) IndexDocument(ctx context.Context, doc *domain.DocumentContent) error

IndexDocument indexes a full document for BM25 text search. Uses document_id as the OpenSearch document _id for upsert semantics.

func (*SearchEngine) Search

func (s *SearchEngine) Search(ctx context.Context, query string, queryEmbedding []float32, opts domain.SearchOptions) ([]*domain.RankedChunk, int, error)

Search performs a BM25 text search

func (*SearchEngine) SearchDocuments

func (s *SearchEngine) SearchDocuments(ctx context.Context, query string, opts domain.SearchOptions) ([]driven.DocumentResult, int, error)

SearchDocuments performs a BM25 text search returning document-level results.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL