Documentation
¶
Index ¶
- func GenerateFakeData(num int, savePath string) ([]map[string]any, error)
- type Config
- type Hit
- type Index
- func (i Index) BatchDelete(ids []string) error
- func (i Index) BatchInsert(data []map[string]any) error
- func (i *Index) Purge() error
- func (i Index) Search(ctx context.Context, query string, sc *SearchConfig) (combined SearchResult, err error)
- func (i Index) Update(datum map[string]any) error
- func (i Index) Upsert(data []map[string]any) error
- type IndexConfig
- type QueryConfig
- type SearchConfig
- type SearchResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
IndexConfig IndexConfig
SearchConfig SearchConfig
}
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
func NewIndex ¶
func NewIndex(ic IndexConfig) (*Index, error)
func (Index) BatchDelete ¶
func (Index) Search ¶
func (i Index) Search(ctx context.Context, query string, sc *SearchConfig) (combined SearchResult, err error)
type IndexConfig ¶
type IndexConfig struct {
ShardNum int `yaml:"shard_num,omitempty" json:"shard_num,omitempty"` // number of shards to use
ShardPath string `yaml:"shard_path,omitempty" json:"shard_path,omitempty"` // filepath to store shard index (if not in-memory)
IdField string `yaml:"id_field,omitempty" json:"id_field,omitempty"` // data field to be used as doc _id
StoreFields []string `yaml:"store_fields,omitempty" json:"store_fields,omitempty"` // fields to be stored in index; if not set, just use composite "_all"
AnalyzerConfig analyzer.ConfigMap `yaml:"analyzer_config,omitempty" json:"analyzer_config,omitempty"` // analyzer config to use per field. use "*" for any field
}
func NewDefaultIndexConfig ¶
func NewDefaultIndexConfig(name, idField string, inMemory bool, ac analyzer.Config) IndexConfig
index config with opinionated defaults
type QueryConfig ¶
type QueryConfig struct {
ImproveFuzziness map[string]bool // improve fuzziness when searching specific fields
FieldBoost map[string]float64 // boost results when searching specific fields
}
func (QueryConfig) GetBoost ¶
func (qc QueryConfig) GetBoost(field string) float64
func (QueryConfig) GetFuzzyness ¶
func (qc QueryConfig) GetFuzzyness(field string) int
type SearchConfig ¶
type SearchConfig struct {
Limit int `yaml:"limit,omitempty" json:"limit,omitempty"` // limit number of results returned; 0 will return all
From int `yaml:"from,omitempty" json:"from,omitempty"` // offset for paging results (to be used with limit)
SearchFields []string `yaml:"search_fields,omitempty" json:"search_fields,omitempty"` // fields to search the query; if not set, search composite "_all"
ReturnFields []string `yaml:"return_fields,omitempty" json:"return_fields,omitempty"` // stored fields to return when getting search results; see IndexConfig.StoreFields to manage fields youre storing
QueryConfig QueryConfig `yaml:"query_config,omitempty" json:"query_config,omitempty"` // this will have no effect if SearchConfig.SearchFields are not set
ScoreThreshold float64 `yaml:"score_threshold,omitempty" json:"score_threshold,omitempty"` // filter results below specified score. if not set, includes all
MaxScorePercentThreshold float64 `yaml:"max_score_percent_threshold,omitempty" json:"max_score_percent_threshold,omitempty"` // filter results below specified percent of max score.
AnalyzerConfig analyzer.ConfigMap `yaml:"analyzer_config,omitempty" json:"analyzer_config,omitempty"` // analyzer config to use per field. use "*" for any field
}
func NewDefaultSearchConfig ¶
func NewDefaultSearchConfig(ac analyzer.Config, returnFields []string) SearchConfig
search config with opinionated defaults note: ImproveFuzziness will impact query speed but improves results
Click to show internal directories.
Click to hide internal directories.