Documentation
¶
Index ¶
- Variables
- func NewExtension(opts ...ConfigOption) forge.Extension
- func NewExtensionWithConfig(config Config) forge.Extension
- type Analyzer
- type AutocompleteQuery
- type AutocompleteResults
- type Completion
- type Config
- type ConfigOption
- func WithAPIKey(apiKey string) ConfigOption
- func WithAuth(username, password string) ConfigOption
- func WithConfig(config Config) ConfigOption
- func WithDefaultLimit(limit int) ConfigOption
- func WithDriver(driver string) ConfigOption
- func WithHosts(hosts ...string) ConfigOption
- func WithMaxConnections(max int) ConfigOption
- func WithMaxLimit(limit int) ConfigOption
- func WithMetrics(enable bool) ConfigOption
- func WithRequireConfig(require bool) ConfigOption
- func WithTLS(certFile, keyFile, caFile string) ConfigOption
- func WithTimeout(timeout time.Duration) ConfigOption
- func WithTracing(enable bool) ConfigOption
- func WithURL(url string) ConfigOption
- type Document
- type ElasticsearchSearch
- func (s *ElasticsearchSearch) Autocomplete(ctx context.Context, query AutocompleteQuery) (*AutocompleteResults, error)
- func (s *ElasticsearchSearch) BulkIndex(ctx context.Context, index string, docs []Document) error
- func (s *ElasticsearchSearch) Connect(ctx context.Context) error
- func (s *ElasticsearchSearch) CreateIndex(ctx context.Context, name string, schema IndexSchema) error
- func (s *ElasticsearchSearch) Delete(ctx context.Context, index string, id string) error
- func (s *ElasticsearchSearch) DeleteIndex(ctx context.Context, name string) error
- func (s *ElasticsearchSearch) Disconnect(ctx context.Context) error
- func (s *ElasticsearchSearch) Get(ctx context.Context, index string, id string) (*Document, error)
- func (s *ElasticsearchSearch) GetIndexInfo(ctx context.Context, name string) (*IndexInfo, error)
- func (s *ElasticsearchSearch) Index(ctx context.Context, index string, doc Document) error
- func (s *ElasticsearchSearch) ListIndexes(ctx context.Context) ([]string, error)
- func (s *ElasticsearchSearch) Ping(ctx context.Context) error
- func (s *ElasticsearchSearch) Search(ctx context.Context, query SearchQuery) (*SearchResults, error)
- func (s *ElasticsearchSearch) Stats(ctx context.Context) (*SearchStats, error)
- func (s *ElasticsearchSearch) Suggest(ctx context.Context, query SuggestQuery) (*SuggestResults, error)
- func (s *ElasticsearchSearch) Update(ctx context.Context, index string, id string, doc Document) error
- type Extension
- type Facet
- type FacetingConfig
- type FieldSchema
- type Filter
- type HighlightConfig
- type Hit
- type InMemorySearch
- func (s *InMemorySearch) Autocomplete(ctx context.Context, query AutocompleteQuery) (*AutocompleteResults, error)
- func (s *InMemorySearch) BulkIndex(ctx context.Context, indexName string, docs []Document) error
- func (s *InMemorySearch) Connect(ctx context.Context) error
- func (s *InMemorySearch) CreateIndex(ctx context.Context, name string, schema IndexSchema) error
- func (s *InMemorySearch) Delete(ctx context.Context, indexName string, id string) error
- func (s *InMemorySearch) DeleteIndex(ctx context.Context, name string) error
- func (s *InMemorySearch) Disconnect(ctx context.Context) error
- func (s *InMemorySearch) Get(ctx context.Context, indexName string, id string) (*Document, error)
- func (s *InMemorySearch) GetIndexInfo(ctx context.Context, name string) (*IndexInfo, error)
- func (s *InMemorySearch) Index(ctx context.Context, indexName string, doc Document) error
- func (s *InMemorySearch) ListIndexes(ctx context.Context) ([]string, error)
- func (s *InMemorySearch) Ping(ctx context.Context) error
- func (s *InMemorySearch) Search(ctx context.Context, query SearchQuery) (*SearchResults, error)
- func (s *InMemorySearch) Stats(ctx context.Context) (*SearchStats, error)
- func (s *InMemorySearch) Suggest(ctx context.Context, query SuggestQuery) (*SuggestResults, error)
- func (s *InMemorySearch) Update(ctx context.Context, indexName string, id string, doc Document) error
- type IndexInfo
- type IndexSchema
- type MeilisearchSearch
- func (s *MeilisearchSearch) Autocomplete(ctx context.Context, query AutocompleteQuery) (*AutocompleteResults, error)
- func (s *MeilisearchSearch) BulkIndex(ctx context.Context, index string, docs []Document) error
- func (s *MeilisearchSearch) Connect(ctx context.Context) error
- func (s *MeilisearchSearch) CreateIndex(ctx context.Context, name string, schema IndexSchema) error
- func (s *MeilisearchSearch) Delete(ctx context.Context, index string, id string) error
- func (s *MeilisearchSearch) DeleteIndex(ctx context.Context, name string) error
- func (s *MeilisearchSearch) Disconnect(ctx context.Context) error
- func (s *MeilisearchSearch) Get(ctx context.Context, index string, id string) (*Document, error)
- func (s *MeilisearchSearch) GetIndexInfo(ctx context.Context, name string) (*IndexInfo, error)
- func (s *MeilisearchSearch) Index(ctx context.Context, index string, doc Document) error
- func (s *MeilisearchSearch) ListIndexes(ctx context.Context) ([]string, error)
- func (s *MeilisearchSearch) Ping(ctx context.Context) error
- func (s *MeilisearchSearch) Search(ctx context.Context, query SearchQuery) (*SearchResults, error)
- func (s *MeilisearchSearch) Stats(ctx context.Context) (*SearchStats, error)
- func (s *MeilisearchSearch) Suggest(ctx context.Context, query SuggestQuery) (*SuggestResults, error)
- func (s *MeilisearchSearch) Update(ctx context.Context, index string, id string, doc Document) error
- type RankingConfig
- type Search
- type SearchQuery
- type SearchResults
- type SearchStats
- type SortField
- type SuggestQuery
- type SuggestResults
- type Suggestion
- type Synonym
- type TypesenseSearch
- func (s *TypesenseSearch) Autocomplete(ctx context.Context, query AutocompleteQuery) (*AutocompleteResults, error)
- func (s *TypesenseSearch) BulkIndex(ctx context.Context, index string, docs []Document) error
- func (s *TypesenseSearch) Connect(ctx context.Context) error
- func (s *TypesenseSearch) CreateIndex(ctx context.Context, name string, schema IndexSchema) error
- func (s *TypesenseSearch) Delete(ctx context.Context, index string, id string) error
- func (s *TypesenseSearch) DeleteIndex(ctx context.Context, name string) error
- func (s *TypesenseSearch) Disconnect(ctx context.Context) error
- func (s *TypesenseSearch) Get(ctx context.Context, index string, id string) (*Document, error)
- func (s *TypesenseSearch) GetIndexInfo(ctx context.Context, name string) (*IndexInfo, error)
- func (s *TypesenseSearch) Index(ctx context.Context, index string, doc Document) error
- func (s *TypesenseSearch) ListIndexes(ctx context.Context) ([]string, error)
- func (s *TypesenseSearch) Ping(ctx context.Context) error
- func (s *TypesenseSearch) Search(ctx context.Context, query SearchQuery) (*SearchResults, error)
- func (s *TypesenseSearch) Stats(ctx context.Context) (*SearchStats, error)
- func (s *TypesenseSearch) Suggest(ctx context.Context, query SuggestQuery) (*SuggestResults, error)
- func (s *TypesenseSearch) Update(ctx context.Context, index string, id string, doc Document) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotConnected = errors.New("search: not connected") ErrAlreadyConnected = errors.New("search: already connected") ErrIndexNotFound = errors.New("search: index not found") ErrIndexAlreadyExists = errors.New("search: index already exists") ErrDocumentNotFound = errors.New("search: document not found") ErrInvalidQuery = errors.New("search: invalid query") ErrInvalidSchema = errors.New("search: invalid schema") ErrConnectionFailed = errors.New("search: connection failed") ErrTimeout = errors.New("search: operation timeout") ErrInvalidConfig = errors.New("search: invalid configuration") ErrUnsupportedDriver = errors.New("search: unsupported driver") ErrOperationFailed = errors.New("search: operation failed") )
Common search errors
Functions ¶
func NewExtension ¶
func NewExtension(opts ...ConfigOption) forge.Extension
NewExtension creates a new search extension with functional options. Config is loaded from ConfigManager by default, with options providing overrides.
Example:
// Load from ConfigManager (tries "extensions.search", then "search")
search.NewExtension()
// Override specific fields
search.NewExtension(
search.WithDriver("elasticsearch"),
search.WithURL("http://localhost:9200"),
)
// Require config from ConfigManager
search.NewExtension(search.WithRequireConfig(true))
func NewExtensionWithConfig ¶
NewExtensionWithConfig creates a new search extension with a complete config. This is for backward compatibility or when config is fully known at initialization.
Types ¶
type Analyzer ¶
type Analyzer struct {
Type string `json:"type"` // standard, simple, whitespace, keyword, pattern
Tokenizer string `json:"tokenizer,omitempty"`
Filters []string `json:"filters,omitempty"`
CharFilters []string `json:"char_filters,omitempty"`
}
Analyzer defines text analysis configuration
type AutocompleteQuery ¶
type AutocompleteQuery struct {
Index string `json:"index"`
Query string `json:"query"`
Field string `json:"field"`
Limit int `json:"limit,omitempty"`
}
AutocompleteQuery represents an autocomplete request
type AutocompleteResults ¶
type AutocompleteResults struct {
Completions []Completion `json:"completions"`
ProcessingTime time.Duration `json:"processing_time_ms"`
}
AutocompleteResults contains autocomplete response
type Completion ¶
Completion represents a single completion
type Config ¶
type Config struct {
// Driver specifies the search backend: "inmemory", "elasticsearch", "meilisearch", "typesense"
Driver string `json:"driver" yaml:"driver" mapstructure:"driver"`
// Connection settings
URL string `json:"url,omitempty" yaml:"url,omitempty" mapstructure:"url"`
Hosts []string `json:"hosts,omitempty" yaml:"hosts,omitempty" mapstructure:"hosts"`
Username string `json:"username,omitempty" yaml:"username,omitempty" mapstructure:"username"`
Password string `json:"password,omitempty" yaml:"password,omitempty" mapstructure:"password"`
APIKey string `json:"api_key,omitempty" yaml:"api_key,omitempty" mapstructure:"api_key"`
// Connection pool
MaxConnections int `json:"max_connections" yaml:"max_connections" mapstructure:"max_connections"`
MaxIdleConnections int `json:"max_idle_connections" yaml:"max_idle_connections" mapstructure:"max_idle_connections"`
ConnectTimeout time.Duration `json:"connect_timeout" yaml:"connect_timeout" mapstructure:"connect_timeout"`
RequestTimeout time.Duration `json:"request_timeout" yaml:"request_timeout" mapstructure:"request_timeout"`
KeepAlive time.Duration `json:"keep_alive" yaml:"keep_alive" mapstructure:"keep_alive"`
// Retry policy
MaxRetries int `json:"max_retries" yaml:"max_retries" mapstructure:"max_retries"`
RetryBackoff time.Duration `json:"retry_backoff" yaml:"retry_backoff" mapstructure:"retry_backoff"`
RetryOnTimeout bool `json:"retry_on_timeout" yaml:"retry_on_timeout" mapstructure:"retry_on_timeout"`
// Default search settings
DefaultLimit int `json:"default_limit" yaml:"default_limit" mapstructure:"default_limit"`
MaxLimit int `json:"max_limit" yaml:"max_limit" mapstructure:"max_limit"`
DefaultMinScore float64 `json:"default_min_score" yaml:"default_min_score" mapstructure:"default_min_score"`
EnableHighlight bool `json:"enable_highlight" yaml:"enable_highlight" mapstructure:"enable_highlight"`
EnableFacets bool `json:"enable_facets" yaml:"enable_facets" mapstructure:"enable_facets"`
// Performance
BulkSize int `json:"bulk_size" yaml:"bulk_size" mapstructure:"bulk_size"`
FlushInterval time.Duration `json:"flush_interval" yaml:"flush_interval" mapstructure:"flush_interval"`
EnableCompression bool `json:"enable_compression" yaml:"enable_compression" mapstructure:"enable_compression"`
// Security
EnableTLS bool `json:"enable_tls" yaml:"enable_tls" mapstructure:"enable_tls"`
TLSCertFile string `json:"tls_cert_file,omitempty" yaml:"tls_cert_file,omitempty" mapstructure:"tls_cert_file"`
TLSKeyFile string `json:"tls_key_file,omitempty" yaml:"tls_key_file,omitempty" mapstructure:"tls_key_file"`
TLSCAFile string `json:"tls_ca_file,omitempty" yaml:"tls_ca_file,omitempty" mapstructure:"tls_ca_file"`
InsecureSkipVerify bool `json:"insecure_skip_verify" yaml:"insecure_skip_verify" mapstructure:"insecure_skip_verify"`
// Monitoring
EnableMetrics bool `json:"enable_metrics" yaml:"enable_metrics" mapstructure:"enable_metrics"`
EnableTracing bool `json:"enable_tracing" yaml:"enable_tracing" mapstructure:"enable_tracing"`
// Config loading flags (not serialized)
RequireConfig bool `json:"-" yaml:"-" mapstructure:"-"`
}
Config contains configuration for the search extension
type ConfigOption ¶
type ConfigOption func(*Config)
ConfigOption is a functional option for Config
func WithAuth ¶
func WithAuth(username, password string) ConfigOption
WithAuth sets authentication credentials
func WithDefaultLimit ¶
func WithDefaultLimit(limit int) ConfigOption
WithDefaultLimit sets default result limit
func WithMaxConnections ¶
func WithMaxConnections(max int) ConfigOption
WithMaxConnections sets max connections
func WithMaxLimit ¶
func WithMaxLimit(limit int) ConfigOption
WithMaxLimit sets maximum result limit
func WithRequireConfig ¶
func WithRequireConfig(require bool) ConfigOption
WithRequireConfig requires config from ConfigManager
func WithTimeout ¶
func WithTimeout(timeout time.Duration) ConfigOption
WithTimeout sets request timeout
type ElasticsearchSearch ¶
type ElasticsearchSearch struct {
// contains filtered or unexported fields
}
ElasticsearchSearch implements Search interface for Elasticsearch
func NewElasticsearchSearch ¶
func NewElasticsearchSearch(config Config, logger forge.Logger, metrics forge.Metrics) (*ElasticsearchSearch, error)
NewElasticsearchSearch creates a new Elasticsearch search instance
func (*ElasticsearchSearch) Autocomplete ¶
func (s *ElasticsearchSearch) Autocomplete(ctx context.Context, query AutocompleteQuery) (*AutocompleteResults, error)
Autocomplete returns Elasticsearch autocomplete results
func (*ElasticsearchSearch) Connect ¶
func (s *ElasticsearchSearch) Connect(ctx context.Context) error
Connect establishes connection to Elasticsearch
func (*ElasticsearchSearch) CreateIndex ¶
func (s *ElasticsearchSearch) CreateIndex(ctx context.Context, name string, schema IndexSchema) error
CreateIndex creates an Elasticsearch index
func (*ElasticsearchSearch) DeleteIndex ¶
func (s *ElasticsearchSearch) DeleteIndex(ctx context.Context, name string) error
DeleteIndex deletes an Elasticsearch index
func (*ElasticsearchSearch) Disconnect ¶
func (s *ElasticsearchSearch) Disconnect(ctx context.Context) error
Disconnect closes the Elasticsearch connection
func (*ElasticsearchSearch) GetIndexInfo ¶
GetIndexInfo returns Elasticsearch index information
func (*ElasticsearchSearch) ListIndexes ¶
func (s *ElasticsearchSearch) ListIndexes(ctx context.Context) ([]string, error)
ListIndexes lists all Elasticsearch indexes
func (*ElasticsearchSearch) Ping ¶
func (s *ElasticsearchSearch) Ping(ctx context.Context) error
Ping checks Elasticsearch health
func (*ElasticsearchSearch) Search ¶
func (s *ElasticsearchSearch) Search(ctx context.Context, query SearchQuery) (*SearchResults, error)
Search performs an Elasticsearch search
func (*ElasticsearchSearch) Stats ¶
func (s *ElasticsearchSearch) Stats(ctx context.Context) (*SearchStats, error)
Stats returns Elasticsearch statistics
func (*ElasticsearchSearch) Suggest ¶
func (s *ElasticsearchSearch) Suggest(ctx context.Context, query SuggestQuery) (*SuggestResults, error)
Suggest returns Elasticsearch suggestions
type Extension ¶
type Extension struct {
*forge.BaseExtension
// contains filtered or unexported fields
}
Extension implements forge.Extension for search functionality
type FacetingConfig ¶
type FacetingConfig struct {
MaxValues int `json:"max_values"`
Sort string `json:"sort"` // count, name
}
FacetingConfig defines faceting options
type FieldSchema ¶
type FieldSchema struct {
Name string `json:"name"`
Type string `json:"type"` // text, keyword, integer, float, boolean, date, geo_point
Required bool `json:"required"`
Searchable bool `json:"searchable"`
Filterable bool `json:"filterable"`
Sortable bool `json:"sortable"`
Faceted bool `json:"faceted"`
Stored bool `json:"stored"`
Index bool `json:"index"`
Boost float64 `json:"boost,omitempty"`
Analyzer string `json:"analyzer,omitempty"`
Format string `json:"format,omitempty"` // For dates
Locale string `json:"locale,omitempty"`
DefaultValue interface{} `json:"default_value,omitempty"`
}
FieldSchema defines a single field in the index
type Filter ¶
type Filter struct {
Field string `json:"field"`
Operator string `json:"operator"` // =, !=, >, >=, <, <=, IN, NOT IN, BETWEEN, EXISTS
Value interface{} `json:"value"`
}
Filter represents a search filter
type HighlightConfig ¶
HighlightConfig defines highlighting options
type Hit ¶
type Hit struct {
ID string `json:"id"`
Score float64 `json:"score"`
Document map[string]interface{} `json:"document"`
Highlights map[string][]string `json:"highlights,omitempty"`
}
Hit represents a single search result
type InMemorySearch ¶
type InMemorySearch struct {
// contains filtered or unexported fields
}
InMemorySearch implements Search interface with an in-memory store
func NewInMemorySearch ¶
NewInMemorySearch creates a new in-memory search instance
func (*InMemorySearch) Autocomplete ¶
func (s *InMemorySearch) Autocomplete(ctx context.Context, query AutocompleteQuery) (*AutocompleteResults, error)
Autocomplete returns autocomplete results
func (*InMemorySearch) Connect ¶
func (s *InMemorySearch) Connect(ctx context.Context) error
Connect establishes connection to the search backend
func (*InMemorySearch) CreateIndex ¶
func (s *InMemorySearch) CreateIndex(ctx context.Context, name string, schema IndexSchema) error
CreateIndex creates a new search index
func (*InMemorySearch) DeleteIndex ¶
func (s *InMemorySearch) DeleteIndex(ctx context.Context, name string) error
DeleteIndex deletes a search index
func (*InMemorySearch) Disconnect ¶
func (s *InMemorySearch) Disconnect(ctx context.Context) error
Disconnect closes the connection to the search backend
func (*InMemorySearch) GetIndexInfo ¶
GetIndexInfo returns information about an index
func (*InMemorySearch) ListIndexes ¶
func (s *InMemorySearch) ListIndexes(ctx context.Context) ([]string, error)
ListIndexes returns a list of all indexes
func (*InMemorySearch) Ping ¶
func (s *InMemorySearch) Ping(ctx context.Context) error
Ping checks if the search backend is responsive
func (*InMemorySearch) Search ¶
func (s *InMemorySearch) Search(ctx context.Context, query SearchQuery) (*SearchResults, error)
Search performs a search query
func (*InMemorySearch) Stats ¶
func (s *InMemorySearch) Stats(ctx context.Context) (*SearchStats, error)
Stats returns search engine statistics
func (*InMemorySearch) Suggest ¶
func (s *InMemorySearch) Suggest(ctx context.Context, query SuggestQuery) (*SuggestResults, error)
Suggest returns search suggestions
type IndexInfo ¶
type IndexInfo struct {
Name string `json:"name"`
DocumentCount int64 `json:"document_count"`
IndexSize int64 `json:"index_size"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Schema IndexSchema `json:"schema"`
}
IndexInfo contains metadata about an index
type IndexSchema ¶
type IndexSchema struct {
Fields []FieldSchema `json:"fields"`
Settings map[string]interface{} `json:"settings,omitempty"`
Synonyms []Synonym `json:"synonyms,omitempty"`
StopWords []string `json:"stop_words,omitempty"`
Analyzers map[string]Analyzer `json:"analyzers,omitempty"`
Ranking *RankingConfig `json:"ranking,omitempty"`
Faceting *FacetingConfig `json:"faceting,omitempty"`
Highlighting *HighlightConfig `json:"highlighting,omitempty"`
}
IndexSchema defines the structure of a search index
type MeilisearchSearch ¶
type MeilisearchSearch struct {
// contains filtered or unexported fields
}
MeilisearchSearch implements Search interface for Meilisearch
func NewMeilisearchSearch ¶
func NewMeilisearchSearch(config Config, logger forge.Logger, metrics forge.Metrics) (*MeilisearchSearch, error)
NewMeilisearchSearch creates a new Meilisearch search instance
func (*MeilisearchSearch) Autocomplete ¶
func (s *MeilisearchSearch) Autocomplete(ctx context.Context, query AutocompleteQuery) (*AutocompleteResults, error)
Autocomplete returns Meilisearch autocomplete results
func (*MeilisearchSearch) Connect ¶
func (s *MeilisearchSearch) Connect(ctx context.Context) error
Connect establishes connection to Meilisearch
func (*MeilisearchSearch) CreateIndex ¶
func (s *MeilisearchSearch) CreateIndex(ctx context.Context, name string, schema IndexSchema) error
CreateIndex creates a Meilisearch index
func (*MeilisearchSearch) DeleteIndex ¶
func (s *MeilisearchSearch) DeleteIndex(ctx context.Context, name string) error
DeleteIndex deletes a Meilisearch index
func (*MeilisearchSearch) Disconnect ¶
func (s *MeilisearchSearch) Disconnect(ctx context.Context) error
Disconnect closes the Meilisearch connection
func (*MeilisearchSearch) GetIndexInfo ¶
GetIndexInfo returns Meilisearch index information
func (*MeilisearchSearch) ListIndexes ¶
func (s *MeilisearchSearch) ListIndexes(ctx context.Context) ([]string, error)
ListIndexes lists all Meilisearch indexes
func (*MeilisearchSearch) Ping ¶
func (s *MeilisearchSearch) Ping(ctx context.Context) error
Ping checks Meilisearch health
func (*MeilisearchSearch) Search ¶
func (s *MeilisearchSearch) Search(ctx context.Context, query SearchQuery) (*SearchResults, error)
Search performs a Meilisearch search
func (*MeilisearchSearch) Stats ¶
func (s *MeilisearchSearch) Stats(ctx context.Context) (*SearchStats, error)
Stats returns Meilisearch statistics
func (*MeilisearchSearch) Suggest ¶
func (s *MeilisearchSearch) Suggest(ctx context.Context, query SuggestQuery) (*SuggestResults, error)
Suggest returns Meilisearch suggestions
type RankingConfig ¶
type RankingConfig struct {
Rules []string `json:"rules"`
Weights map[string]float64 `json:"weights,omitempty"`
}
RankingConfig defines ranking rules
type Search ¶
type Search interface {
// Connection management
Connect(ctx context.Context) error
Disconnect(ctx context.Context) error
Ping(ctx context.Context) error
// Index management
CreateIndex(ctx context.Context, name string, schema IndexSchema) error
DeleteIndex(ctx context.Context, name string) error
ListIndexes(ctx context.Context) ([]string, error)
GetIndexInfo(ctx context.Context, name string) (*IndexInfo, error)
// Document operations
Index(ctx context.Context, index string, doc Document) error
BulkIndex(ctx context.Context, index string, docs []Document) error
Get(ctx context.Context, index string, id string) (*Document, error)
Delete(ctx context.Context, index string, id string) error
Update(ctx context.Context, index string, id string, doc Document) error
// Search operations
Search(ctx context.Context, query SearchQuery) (*SearchResults, error)
Suggest(ctx context.Context, query SuggestQuery) (*SuggestResults, error)
Autocomplete(ctx context.Context, query AutocompleteQuery) (*AutocompleteResults, error)
// Analytics
Stats(ctx context.Context) (*SearchStats, error)
}
Search represents a unified search interface supporting multiple backends
type SearchQuery ¶
type SearchQuery struct {
Index string `json:"index"`
Query string `json:"query"`
Filters []Filter `json:"filters,omitempty"`
Sort []SortField `json:"sort,omitempty"`
Facets []string `json:"facets,omitempty"`
Offset int `json:"offset,omitempty"`
Limit int `json:"limit,omitempty"`
Highlight bool `json:"highlight,omitempty"`
HighlightFields []string `json:"highlight_fields,omitempty"`
Fields []string `json:"fields,omitempty"` // Fields to return
MinScore float64 `json:"min_score,omitempty"`
BoostFields map[string]float64 `json:"boost_fields,omitempty"`
FuzzyLevel int `json:"fuzzy_level,omitempty"` // 0=exact, 1-2=fuzzy
Options map[string]interface{} `json:"options,omitempty"`
}
SearchQuery represents a search request
type SearchResults ¶
type SearchResults struct {
Hits []Hit `json:"hits"`
Total int64 `json:"total"`
Offset int `json:"offset"`
Limit int `json:"limit"`
ProcessingTime time.Duration `json:"processing_time_ms"`
Facets map[string][]Facet `json:"facets,omitempty"`
Query string `json:"query"`
Exhaustive bool `json:"exhaustive"`
}
SearchResults contains search response
type SearchStats ¶
type SearchStats struct {
IndexCount int64 `json:"index_count"`
DocumentCount int64 `json:"document_count"`
TotalSize int64 `json:"total_size"`
Queries int64 `json:"queries"`
AvgLatency time.Duration `json:"avg_latency_ms"`
Uptime time.Duration `json:"uptime"`
Version string `json:"version"`
Extra map[string]interface{} `json:"extra,omitempty"`
}
SearchStats contains search engine statistics
type SuggestQuery ¶
type SuggestQuery struct {
Index string `json:"index"`
Query string `json:"query"`
Field string `json:"field"`
Limit int `json:"limit,omitempty"`
Fuzzy bool `json:"fuzzy,omitempty"`
}
SuggestQuery represents a suggestion request
type SuggestResults ¶
type SuggestResults struct {
Suggestions []Suggestion `json:"suggestions"`
ProcessingTime time.Duration `json:"processing_time_ms"`
}
SuggestResults contains suggestion response
type Suggestion ¶
Suggestion represents a single suggestion
type TypesenseSearch ¶
type TypesenseSearch struct {
// contains filtered or unexported fields
}
TypesenseSearch implements Search interface for Typesense
func NewTypesenseSearch ¶
func NewTypesenseSearch(config Config, logger forge.Logger, metrics forge.Metrics) (*TypesenseSearch, error)
NewTypesenseSearch creates a new Typesense search instance
func (*TypesenseSearch) Autocomplete ¶
func (s *TypesenseSearch) Autocomplete(ctx context.Context, query AutocompleteQuery) (*AutocompleteResults, error)
Autocomplete returns Typesense autocomplete results
func (*TypesenseSearch) Connect ¶
func (s *TypesenseSearch) Connect(ctx context.Context) error
Connect establishes connection to Typesense
func (*TypesenseSearch) CreateIndex ¶
func (s *TypesenseSearch) CreateIndex(ctx context.Context, name string, schema IndexSchema) error
CreateIndex creates a Typesense collection
func (*TypesenseSearch) DeleteIndex ¶
func (s *TypesenseSearch) DeleteIndex(ctx context.Context, name string) error
DeleteIndex deletes a Typesense collection
func (*TypesenseSearch) Disconnect ¶
func (s *TypesenseSearch) Disconnect(ctx context.Context) error
Disconnect closes the Typesense connection
func (*TypesenseSearch) GetIndexInfo ¶
GetIndexInfo returns Typesense collection information
func (*TypesenseSearch) ListIndexes ¶
func (s *TypesenseSearch) ListIndexes(ctx context.Context) ([]string, error)
ListIndexes lists all Typesense collections
func (*TypesenseSearch) Ping ¶
func (s *TypesenseSearch) Ping(ctx context.Context) error
Ping checks Typesense health
func (*TypesenseSearch) Search ¶
func (s *TypesenseSearch) Search(ctx context.Context, query SearchQuery) (*SearchResults, error)
Search performs a Typesense search
func (*TypesenseSearch) Stats ¶
func (s *TypesenseSearch) Stats(ctx context.Context) (*SearchStats, error)
Stats returns Typesense statistics
func (*TypesenseSearch) Suggest ¶
func (s *TypesenseSearch) Suggest(ctx context.Context, query SuggestQuery) (*SuggestResults, error)
Suggest returns Typesense suggestions