search

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func NewExtensionWithConfig(config Config) forge.Extension

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

type Completion struct {
	Text  string  `json:"text"`
	Score float64 `json:"score"`
}

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

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns default search configuration

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration

type ConfigOption

type ConfigOption func(*Config)

ConfigOption is a functional option for Config

func WithAPIKey

func WithAPIKey(apiKey string) ConfigOption

WithAPIKey sets the API key

func WithAuth

func WithAuth(username, password string) ConfigOption

WithAuth sets authentication credentials

func WithConfig

func WithConfig(config Config) ConfigOption

WithConfig sets the complete config

func WithDefaultLimit

func WithDefaultLimit(limit int) ConfigOption

WithDefaultLimit sets default result limit

func WithDriver

func WithDriver(driver string) ConfigOption

WithDriver sets the driver

func WithHosts

func WithHosts(hosts ...string) ConfigOption

WithHosts sets the hosts

func WithMaxConnections

func WithMaxConnections(max int) ConfigOption

WithMaxConnections sets max connections

func WithMaxLimit

func WithMaxLimit(limit int) ConfigOption

WithMaxLimit sets maximum result limit

func WithMetrics

func WithMetrics(enable bool) ConfigOption

WithMetrics enables metrics

func WithRequireConfig

func WithRequireConfig(require bool) ConfigOption

WithRequireConfig requires config from ConfigManager

func WithTLS

func WithTLS(certFile, keyFile, caFile string) ConfigOption

WithTLS enables TLS

func WithTimeout

func WithTimeout(timeout time.Duration) ConfigOption

WithTimeout sets request timeout

func WithTracing

func WithTracing(enable bool) ConfigOption

WithTracing enables tracing

func WithURL

func WithURL(url string) ConfigOption

WithURL sets the URL

type Document

type Document struct {
	ID     string                 `json:"id"`
	Fields map[string]interface{} `json:"fields"`
}

Document represents a searchable document

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

Autocomplete returns Elasticsearch autocomplete results

func (*ElasticsearchSearch) BulkIndex

func (s *ElasticsearchSearch) BulkIndex(ctx context.Context, index string, docs []Document) error

BulkIndex bulk indexes documents in Elasticsearch

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) Delete

func (s *ElasticsearchSearch) Delete(ctx context.Context, index string, id string) error

Delete deletes a document from Elasticsearch

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) Get

func (s *ElasticsearchSearch) Get(ctx context.Context, index string, id string) (*Document, error)

Get retrieves a document from Elasticsearch

func (*ElasticsearchSearch) GetIndexInfo

func (s *ElasticsearchSearch) GetIndexInfo(ctx context.Context, name string) (*IndexInfo, error)

GetIndexInfo returns Elasticsearch index information

func (*ElasticsearchSearch) Index

func (s *ElasticsearchSearch) Index(ctx context.Context, index string, doc Document) error

Index indexes a document in Elasticsearch

func (*ElasticsearchSearch) ListIndexes

func (s *ElasticsearchSearch) ListIndexes(ctx context.Context) ([]string, error)

ListIndexes lists all Elasticsearch indexes

func (*ElasticsearchSearch) Ping

Ping checks Elasticsearch health

func (*ElasticsearchSearch) Search

Search performs an Elasticsearch search

func (*ElasticsearchSearch) Stats

Stats returns Elasticsearch statistics

func (*ElasticsearchSearch) Suggest

Suggest returns Elasticsearch suggestions

func (*ElasticsearchSearch) Update

func (s *ElasticsearchSearch) Update(ctx context.Context, index string, id string, doc Document) error

Update updates a document in Elasticsearch

type Extension

type Extension struct {
	*forge.BaseExtension
	// contains filtered or unexported fields
}

Extension implements forge.Extension for search functionality

func (*Extension) Health

func (e *Extension) Health(ctx context.Context) error

Health checks if the search is healthy

func (*Extension) Register

func (e *Extension) Register(app forge.App) error

Register registers the search extension with the app

func (*Extension) Search

func (e *Extension) Search() Search

Search returns the search instance (for advanced usage)

func (*Extension) Start

func (e *Extension) Start(ctx context.Context) error

Start starts the search extension

func (*Extension) Stop

func (e *Extension) Stop(ctx context.Context) error

Stop stops the search extension

type Facet

type Facet struct {
	Value string `json:"value"`
	Count int64  `json:"count"`
}

Facet represents a facet value

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

type HighlightConfig struct {
	PreTag  string `json:"pre_tag"`
	PostTag string `json:"post_tag"`
}

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

func NewInMemorySearch(config Config, logger forge.Logger, metrics forge.Metrics) *InMemorySearch

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) BulkIndex

func (s *InMemorySearch) BulkIndex(ctx context.Context, indexName string, docs []Document) error

BulkIndex adds or updates multiple documents

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) Delete

func (s *InMemorySearch) Delete(ctx context.Context, indexName string, id string) error

Delete removes a document from the 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) Get

func (s *InMemorySearch) Get(ctx context.Context, indexName string, id string) (*Document, error)

Get retrieves a document by ID

func (*InMemorySearch) GetIndexInfo

func (s *InMemorySearch) GetIndexInfo(ctx context.Context, name string) (*IndexInfo, error)

GetIndexInfo returns information about an index

func (*InMemorySearch) Index

func (s *InMemorySearch) Index(ctx context.Context, indexName string, doc Document) error

Index adds or updates a document in the 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

func (*InMemorySearch) Update

func (s *InMemorySearch) Update(ctx context.Context, indexName string, id string, doc Document) error

Update updates a document in the index

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

Autocomplete returns Meilisearch autocomplete results

func (*MeilisearchSearch) BulkIndex

func (s *MeilisearchSearch) BulkIndex(ctx context.Context, index string, docs []Document) error

BulkIndex bulk indexes documents in Meilisearch

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) Delete

func (s *MeilisearchSearch) Delete(ctx context.Context, index string, id string) error

Delete deletes a document from Meilisearch

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) Get

func (s *MeilisearchSearch) Get(ctx context.Context, index string, id string) (*Document, error)

Get retrieves a document from Meilisearch

func (*MeilisearchSearch) GetIndexInfo

func (s *MeilisearchSearch) GetIndexInfo(ctx context.Context, name string) (*IndexInfo, error)

GetIndexInfo returns Meilisearch index information

func (*MeilisearchSearch) Index

func (s *MeilisearchSearch) Index(ctx context.Context, index string, doc Document) error

Index indexes a document in Meilisearch

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

Stats returns Meilisearch statistics

func (*MeilisearchSearch) Suggest

Suggest returns Meilisearch suggestions

func (*MeilisearchSearch) Update

func (s *MeilisearchSearch) Update(ctx context.Context, index string, id string, doc Document) error

Update updates a document in Meilisearch

type RankingConfig

type RankingConfig struct {
	Rules   []string           `json:"rules"`
	Weights map[string]float64 `json:"weights,omitempty"`
}

RankingConfig defines ranking rules

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 SortField

type SortField struct {
	Field string `json:"field"`
	Order string `json:"order"` // asc, desc
}

SortField defines sorting

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

type Suggestion struct {
	Text  string  `json:"text"`
	Score float64 `json:"score"`
}

Suggestion represents a single suggestion

type Synonym

type Synonym struct {
	Terms []string `json:"terms"`
}

Synonym defines term synonyms

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

Autocomplete returns Typesense autocomplete results

func (*TypesenseSearch) BulkIndex

func (s *TypesenseSearch) BulkIndex(ctx context.Context, index string, docs []Document) error

BulkIndex bulk indexes documents in Typesense

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) Delete

func (s *TypesenseSearch) Delete(ctx context.Context, index string, id string) error

Delete deletes a document from Typesense

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) Get

func (s *TypesenseSearch) Get(ctx context.Context, index string, id string) (*Document, error)

Get retrieves a document from Typesense

func (*TypesenseSearch) GetIndexInfo

func (s *TypesenseSearch) GetIndexInfo(ctx context.Context, name string) (*IndexInfo, error)

GetIndexInfo returns Typesense collection information

func (*TypesenseSearch) Index

func (s *TypesenseSearch) Index(ctx context.Context, index string, doc Document) error

Index indexes a document in Typesense

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

func (*TypesenseSearch) Update

func (s *TypesenseSearch) Update(ctx context.Context, index string, id string, doc Document) error

Update updates a document in Typesense

Jump to

Keyboard shortcuts

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