Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Aggregator ¶
type Aggregator struct {
// contains filtered or unexported fields
}
Aggregator aggregates results from multiple search engines
func NewAggregator ¶
func NewAggregator(engines []Engine, config AggregatorConfig) *Aggregator
NewAggregator creates a new search aggregator
func NewAggregatorSimple ¶
func NewAggregatorSimple(engines []Engine, timeout time.Duration) *Aggregator
NewAggregatorSimple creates an aggregator with default settings (backwards compatible)
func (*Aggregator) Search ¶
func (a *Aggregator) Search(ctx context.Context, query *model.Query) (*model.SearchResults, error)
Search performs concurrent searches across all engines
type AggregatorConfig ¶
type AggregatorConfig struct {
Timeout time.Duration
CacheEnabled bool
CacheTTL time.Duration
MaxCacheSize int
}
AggregatorConfig holds aggregator configuration
type BaseEngine ¶
type BaseEngine struct {
// contains filtered or unexported fields
}
BaseEngine provides common functionality for engines
func NewBaseEngine ¶
func NewBaseEngine(config *model.EngineConfig) *BaseEngine
NewBaseEngine creates a new BaseEngine
func (*BaseEngine) DisplayName ¶
func (e *BaseEngine) DisplayName() string
DisplayName returns the display name
func (*BaseEngine) GetConfig ¶
func (e *BaseEngine) GetConfig() *model.EngineConfig
GetConfig returns the engine configuration
func (*BaseEngine) GetPriority ¶
func (e *BaseEngine) GetPriority() int
GetPriority returns the engine priority
func (*BaseEngine) IsEnabled ¶
func (e *BaseEngine) IsEnabled() bool
IsEnabled returns whether the engine is enabled
func (*BaseEngine) SupportsCategory ¶
func (e *BaseEngine) SupportsCategory(category model.Category) bool
SupportsCategory returns whether the engine supports a category
type CacheStats ¶
type CacheStats struct {
Size int `json:"size"`
MaxSize int `json:"max_size"`
Hits int64 `json:"hits"`
Misses int64 `json:"misses"`
HitRate float64 `json:"hit_rate"`
}
Stats returns cache statistics
type Engine ¶
type Engine interface {
// Name returns the unique engine name
Name() string
// DisplayName returns the human-readable engine name
DisplayName() string
// Search performs a search and returns results
Search(ctx context.Context, query *model.Query) ([]model.Result, error)
// IsEnabled returns whether the engine is enabled
IsEnabled() bool
// GetPriority returns the engine priority (higher = more important)
GetPriority() int
// SupportsCategory returns whether the engine supports a category
SupportsCategory(category model.Category) bool
// GetConfig returns the engine configuration
GetConfig() *model.EngineConfig
}
Engine represents a search engine interface
type RelatedSearches ¶
type RelatedSearches struct {
// contains filtered or unexported fields
}
RelatedSearches provides related search suggestions
func NewRelatedSearches ¶
func NewRelatedSearches() *RelatedSearches
NewRelatedSearches creates a new related searches provider
func (*RelatedSearches) ClearCache ¶
func (rs *RelatedSearches) ClearCache()
ClearCache clears the entire cache
func (*RelatedSearches) GetRelated ¶
func (rs *RelatedSearches) GetRelated(ctx context.Context, query string, limit int) ([]string, error)
GetRelated returns related search suggestions for a query
type ResultCache ¶
type ResultCache struct {
// contains filtered or unexported fields
}
ResultCache provides an in-memory cache for search results
func NewResultCache ¶
func NewResultCache(maxSize int, ttl time.Duration) *ResultCache
NewResultCache creates a new result cache
func (*ResultCache) Delete ¶
func (c *ResultCache) Delete(key string)
Delete removes an item from the cache
func (*ResultCache) Get ¶
func (c *ResultCache) Get(key string) *model.SearchResults
Get retrieves cached results for a key
func (*ResultCache) Set ¶
func (c *ResultCache) Set(key string, results *model.SearchResults)
Set stores results in the cache
func (*ResultCache) Size ¶
func (c *ResultCache) Size() int
Size returns the current number of cached items
func (*ResultCache) Stats ¶
func (c *ResultCache) Stats() CacheStats
type SearchOperators ¶
type SearchOperators struct {
// Original and cleaned query
OriginalQuery string
CleanedQuery string
// Site restriction
Site string // site:example.com
Sites []string // Multiple sites
ExcludeSite string // -site:example.com
// File type
FileType string // filetype:pdf
FileTypes []string // Multiple file types
// URL filters
InURL string // inurl:keyword
InTitle string // intitle:keyword
AllInURL string // allinurl:keyword1 keyword2
// Content filters
InText string // intext:keyword
AllInText string // allintext:keyword1 keyword2
InAnchor string // inanchor:keyword
AllInAnchor string // allinanchor:keyword1 keyword2
// Exact match
ExactPhrases []string // "exact phrase"
// Exclusions
ExcludeTerms []string // -word
// Related/cache
Related string // related:example.com
Cache string // cache:example.com
Info string // info:example.com
// Date range
DateRange string // daterange:start-end
Before string // before:2024-01-01
After string // after:2023-01-01
// Numeric range
NumRange string // $100..$500 or 100..500
// Boolean operators
HasOR bool // Contains OR operator
HasAND bool // Contains AND operator
// Special operators
Define string // define:word
Weather string // weather:city
Stocks string // stocks:AAPL
Map string // map:location
Movie string // movie:title
Source string // source:nytimes (news)
Location string // loc:city or location:city
Language string // lang:en
// Wildcard
HasWildcard bool // Contains * wildcard
}
SearchOperators contains parsed search operators from query text
func ParseOperators ¶
func ParseOperators(query string) *SearchOperators
ParseOperators extracts search operators from query text
func (*SearchOperators) HasOperators ¶
func (ops *SearchOperators) HasOperators() bool
HasOperators returns true if any operators were found
func (*SearchOperators) ToBasicQuery ¶
func (ops *SearchOperators) ToBasicQuery() string
ToBasicQuery returns the cleaned query without operators for engines that don't support advanced operators
func (*SearchOperators) ToBingQuery ¶
func (ops *SearchOperators) ToBingQuery() string
ToBingQuery converts operators to Bing-compatible query string
func (*SearchOperators) ToDuckDuckGoQuery ¶
func (ops *SearchOperators) ToDuckDuckGoQuery() string
ToDuckDuckGoQuery converts operators to DuckDuckGo-compatible query string
func (*SearchOperators) ToGoogleQuery ¶
func (ops *SearchOperators) ToGoogleQuery() string
ToGoogleQuery converts operators to Google-compatible query string