config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDecodeConfig             = errors.New("failed to decode config file")
	ErrMissingMeilisearchConfig = errors.New("meilisearch configuration is missing")
	ErrAPIUrlRequire            = errors.New("meilisearch api_url is required")
	ErrMissingSourceConfig      = errors.New("source configuration is missing")
	ErrNotSupportedEngine       = errors.New("engine is not supported")
	ErrSourceURIRequire         = errors.New("source uri is required")
	ErrSourceDatabaseRequire    = errors.New("source database is required")
	ErrMissingBridgeConfig      = errors.New("bridge configuration is missing")
	ErrCollectionRequire        = errors.New("bridge collection is required")
	ErrIndexNameRequire         = errors.New("bridge index_name is required")
	ErrInvalidPrimaryKey        = errors.New("don't match primary key with field value map")
)

Functions

This section is empty.

Types

type Bridge

type Bridge struct {
	Collection string            `yaml:"collection"`
	IndexName  string            `yaml:"index_name"`
	Fields     map[string]string `yaml:"fields"`
	Settings   *BridgeSettings   `yaml:"settings"`
}

type BridgeSettings

type BridgeSettings struct {
	PrimaryKey string    `yaml:"primary_key"`
	Settings   *Settings `yaml:"index_settings"`
}

type Config

type Config struct {
	Meilisearch *Meilisearch `yaml:"meilisearch"`
	Source      *Source      `yaml:"source"`
	Bridges     []*Bridge    `yaml:"bridges"`
}

func New

func New(configPath string) (*Config, error)

func (*Config) Validate

func (c *Config) Validate() error

type Embedder

type Embedder struct {
	Source           string `json:"source" yaml:"source"`
	ApiKey           string `json:"apiKey,omitempty" yaml:"api_key"`
	Model            string `json:"model,omitempty" yaml:"model"`
	Dimensions       int    `json:"dimensions,omitempty" yaml:"dimensions"`
	DocumentTemplate string `json:"documentTemplate,omitempty" yaml:"document_template"`
}

type Engine

type Engine string
const (
	MONGO    Engine = "mongo"
	MYSQL    Engine = "mysql"
	POSTGRES Engine = "postgres"
)

func (Engine) String

func (e Engine) String() string

type Faceting

type Faceting struct {
	MaxValuesPerFacet int64 `json:"maxValuesPerFacet" yaml:"max_values_per_facet"`
}

type Meilisearch

type Meilisearch struct {
	APIURL string `yaml:"api_url"`
	APIKey string `yaml:"api_key"`
}

type MinWordSizeForTypos

type MinWordSizeForTypos struct {
	OneTypo  int64 `json:"oneTypo,omitempty" yaml:"one_typo"`
	TwoTypos int64 `json:"twoTypos,omitempty" yaml:"two_typos"`
}

type Pagination

type Pagination struct {
	MaxTotalHits int64 `json:"maxTotalHits" yaml:"max_total_hits"`
}

type Settings

type Settings struct {
	RankingRules         []string            `json:"rankingRules,omitempty" yaml:"ranking_rules"`
	DistinctAttribute    *string             `json:"distinctAttribute,omitempty" yaml:"distinct_attribute"`
	SearchableAttributes []string            `json:"searchableAttributes,omitempty" yaml:"searchable_attributes"`
	DisplayedAttributes  []string            `json:"displayedAttributes,omitempty" yaml:"displayed_attributes"`
	StopWords            []string            `json:"stopWords,omitempty" yaml:"stop_words"`
	Synonyms             map[string][]string `json:"synonyms,omitempty" yaml:"synonyms"`
	FilterableAttributes []string            `json:"filterableAttributes,omitempty" yaml:"filterable_attributes"`
	SortableAttributes   []string            `json:"sortableAttributes,omitempty" yaml:"sortable_attributes"`
	TypoTolerance        *TypoTolerance      `json:"typoTolerance,omitempty" yaml:"typo_tolerance"`
	Pagination           *Pagination         `json:"pagination,omitempty" yaml:"pagination"`
	Faceting             *Faceting           `json:"faceting,omitempty" yaml:"faceting"`
	Embedders            map[string]Embedder `json:"embedders,omitempty" yaml:"embedders"`
}

type Source

type Source struct {
	Engine   Engine `yaml:"engine"`
	URI      string `yaml:"uri"`
	Database string `yaml:"database"`
}

type TypoTolerance

type TypoTolerance struct {
	Enabled             bool                `json:"enabled,omitempty" yaml:"enabled"`
	MinWordSizeForTypos MinWordSizeForTypos `json:"minWordSizeForTypos,omitempty" yaml:"min_word_size_for_typos"`
	DisableOnWords      []string            `json:"disableOnWords,omitempty" yaml:"disable_on_words"`
	DisableOnAttributes []string            `json:"disableOnAttributes,omitempty" yaml:"disable_on_attributes"`
}

Jump to

Keyboard shortcuts

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