Documentation
¶
Index ¶
- Variables
- func RegisterAdapterFactory(engine Engine, factory AdapterFactory)
- type Adapter
- type AdapterFactory
- type Client
- func (c *Client) BulkDelete(ctx context.Context, index string, documentIDs []string) error
- func (c *Client) BulkIndex(ctx context.Context, index string, documents []any) error
- func (c *Client) BulkIndexWith(ctx context.Context, engine Engine, index string, documents []any) error
- func (c *Client) Delete(ctx context.Context, index, documentID string) error
- func (c *Client) GetAvailableEngines() []Engine
- func (c *Client) GetEngine() Engine
- func (c *Client) GetIndexPrefix() string
- func (c *Client) GetSearchConfig() *Config
- func (c *Client) Health(ctx context.Context) map[Engine]error
- func (c *Client) Index(ctx context.Context, req *IndexRequest) error
- func (c *Client) IndexWith(ctx context.Context, engine Engine, req *IndexRequest) error
- func (c *Client) Search(ctx context.Context, req *Request) (*Response, error)
- func (c *Client) SearchWith(ctx context.Context, engine Engine, req *Request) (*Response, error)
- func (c *Client) SetIndexPrefix(prefix string)
- func (c *Client) UpdateSearchConfig(searchConfig *Config)
- type Collector
- type Config
- type Engine
- type Hit
- type IndexRequest
- type IndexSettings
- type NoOpCollector
- type Request
- type Response
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoEngineAvailable = errors.New("no search engine available") ErrEngineNotFound = errors.New("search engine not found") )
Search engine error definitions
Functions ¶
func RegisterAdapterFactory ¶
func RegisterAdapterFactory(engine Engine, factory AdapterFactory)
RegisterAdapterFactory registers a factory for creating search adapters This is called by search driver packages in their init() functions
Types ¶
type Adapter ¶
type Adapter interface {
Search(ctx context.Context, req *Request) (*Response, error)
Index(ctx context.Context, req *IndexRequest) error
Delete(ctx context.Context, index, id string) error
BulkIndex(ctx context.Context, index string, documents []any) error
BulkDelete(ctx context.Context, index string, documentIDs []string) error
IndexExists(ctx context.Context, indexName string) (bool, error)
CreateIndex(ctx context.Context, indexName string, settings *IndexSettings) error
Health(ctx context.Context) error
Type() Engine
}
Adapter defines the interface for search engine implementations
type AdapterFactory ¶
AdapterFactory creates search adapters from data connections
func GetAdapterFactory ¶
func GetAdapterFactory(engine Engine) (AdapterFactory, error)
GetAdapterFactory returns the factory for a given engine
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client manages search operations across multiple search engines
func NewClientWithConfig ¶
NewClientWithConfig creates a new search client with configuration
func NewClientWithPrefix ¶
NewClientWithPrefix creates a new search client with index prefix
func (*Client) BulkDelete ¶
func (*Client) BulkIndexWith ¶
func (*Client) GetAvailableEngines ¶
func (*Client) GetIndexPrefix ¶
func (*Client) GetSearchConfig ¶
func (*Client) SearchWith ¶
func (*Client) SetIndexPrefix ¶
func (*Client) UpdateSearchConfig ¶
type Collector ¶
type Collector interface {
SearchQuery(engine string, err error)
SearchIndex(engine, operation string)
}
Collector interface for metrics collection
type Config ¶
type Config struct {
IndexPrefix string
DefaultEngine string
AutoCreateIndex bool
IndexSettings *IndexSettings
}
Config represents search engine configuration
type Engine ¶
type Engine string
Engine represents the type of search engine
const ( Elasticsearch Engine = "elasticsearch" OpenSearch Engine = "opensearch" Meilisearch Engine = "meilisearch" )
Supported search engine constants
func GetRegisteredEngines ¶
func GetRegisteredEngines() []Engine
GetRegisteredEngines returns list of engines with registered factories
type Hit ¶
type Hit struct {
ID string `json:"id"`
Score float64 `json:"score"`
Source map[string]any `json:"source"`
}
Hit represents a single search result
type IndexRequest ¶
type IndexRequest struct {
Index string `json:"index"`
DocumentID string `json:"document_id,omitempty"`
Document any `json:"document"`
}
IndexRequest represents a document indexing request
type IndexSettings ¶
type IndexSettings struct {
Shards int
Replicas int
RefreshInterval string
SearchableFields []string
FilterableFields []string
}
IndexSettings represents default index configuration
type NoOpCollector ¶
type NoOpCollector struct{}
NoOpCollector is a no-op implementation of Collector
func (NoOpCollector) SearchIndex ¶
func (NoOpCollector) SearchIndex(string, string)
func (NoOpCollector) SearchQuery ¶
func (NoOpCollector) SearchQuery(string, error)