searchrelevancy

package
v0.0.0-...-0fffe9f Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SearchRelevancyCacheMutex = sync.RWMutex{}

SearchRelevancyCacheMutex to handle concurrent map writes

View Source
var SearchRelevancySettingsCache = map[string]SearchRelevancyStruct{}

SearchRelevancySettingsCache variable to cache settings

Functions

func GetSearchRelevancySettingsFromCache

func GetSearchRelevancySettingsFromCache() map[string]SearchRelevancyStruct

GetSearchRelevancySettingsFromCache to get all settings from cache

func RemoveFromSearchRelevancyCache

func RemoveFromSearchRelevancyCache(index string)

RemoveFromSearchRelevancyCache function to remove from cache

func SetSearchRelevancySettingsCache

func SetSearchRelevancySettingsCache(settings map[string]SearchRelevancyStruct)

SetSearchRelevancySettingsCache to set all settings in cache

func UpdateSearchRelevancyCache

func UpdateSearchRelevancyCache(index string, setting SearchRelevancyStruct)

UpdateSearchRelevancyCache to update existing setting or add new setting

Types

type AggregationStruct

type AggregationStruct struct {
	DataField         map[string]string      `json:"dataField"`
	Size              int                    `json:"size" validate:"gte=0,lte=1000"`
	SortBy            *querytranslate.SortBy `json:"sortBy"`
	IncludeNullValues bool                   `json:"includeNullValues"`
	QueryFormat       *string                `json:"queryFormat"`
}

AggregationStruct aggregation settings struct

type CacheSyncScript

type CacheSyncScript struct {
	// contains filtered or unexported fields
}

func (CacheSyncScript) Index

func (s CacheSyncScript) Index() string

func (CacheSyncScript) PluginName

func (s CacheSyncScript) PluginName() string

func (CacheSyncScript) SetCache

func (s CacheSyncScript) SetCache(response *elastic.SearchResult) error

type IndexSettingStruct

type IndexSettingStruct struct {
	EnableNgram            bool          `json:"enableNgram,omitempty"`
	EnableAutosuggestion   bool          `json:"enableAutoSuggestion,omitempty"`
	NgramSettings          NgramSettings `json:"ngramSettings,omitempty"`
	AutosuggestionSettings NgramSettings `json:"autosuggestionSettings,omitempty"`
}

IndexSettingStruct to store index related settings

type LanguageStruct

type LanguageStruct struct {
	Language            string   `json:"language"`
	ApplyStopwords      bool     `json:"applyStopwords"`
	CustomStopwords     []string `json:"customStopwords"`
	StemmingExceptions  []string `json:"stemmingExceptions"`
	NormalizeDiacritics bool     `json:"normalizeDiacritics"`
}

LanguageStruct language settings struct

type NgramSettings

type NgramSettings struct {
	MinGram int `json:"min_gram,omitempty"`
	MaxGram int `json:"max_gram,omitempty"`
}

type ResultStruct

type ResultStruct struct {
	Size             int                    `json:"size" validate:"gte=0,lte=1000"`
	IncludeFields    []string               `json:"includeFields"`
	ExcludeFields    []string               `json:"excludeFields"`
	Highlight        bool                   `json:"highlight"`
	HighlightFields  []string               `json:"highlightFields"`
	HighlightOptions map[string]interface{} `json:"highlightOptions"`
	SortOptions      []SortOption           `json:"sortOptions,omitempty"`
}

ResultStruct result settings struct

type RulesStruct

type RulesStruct struct {
	Enabled bool `json:"enabled"`
}

RulesStruct to identify if rules are query enabled or not

type SearchRelevancy

type SearchRelevancy struct {
	// contains filtered or unexported fields
}

SearchRelevancy plugin saves default settings for search, aggregations, result, language.

func Instance

func Instance() *SearchRelevancy

Instance returns the singleton instace of SearchRelevancy plugin. Note: Only this function must be used (both within and outside the package) to obtain the instance searchRelevancySettings in order to avoid stateless instances of the plugin.

func (*SearchRelevancy) AlternateRoutes

func (a *SearchRelevancy) AlternateRoutes() []plugins.Route

Expose plugin specific routes

func (*SearchRelevancy) ESMiddleware

func (a *SearchRelevancy) ESMiddleware() []middleware.Middleware

ESMiddleware ES middlewares

func (*SearchRelevancy) InitFunc

func (a *SearchRelevancy) InitFunc() error

InitFunc is a part of Plugin interface that gets executed only once, and initializes the dao, i.e. elasticsearch before the plugin is operational.

func (*SearchRelevancy) Name

func (a *SearchRelevancy) Name() string

Name is a part of Plugin interface that returns the name of the plugin: '[searchsetttings]'.

func (*SearchRelevancy) RSMiddleware

func (a *SearchRelevancy) RSMiddleware() []middleware.Middleware

RSMiddleware RS middlewares

func (*SearchRelevancy) Routes

func (a *SearchRelevancy) Routes() []plugins.Route

Routes returns the searchrelevancy routes that the plugin serves.

type SearchRelevancyStruct

type SearchRelevancyStruct struct {
	Search        *SearchStruct       `json:"search"`
	Aggregations  *AggregationStruct  `json:"aggregations"`
	Results       *ResultStruct       `json:"results"`
	Language      *LanguageStruct     `json:"language"`
	Synonyms      *SynonymsStruct     `json:"synonyms"`
	Rules         *RulesStruct        `json:"rules"`
	IndexSettings *IndexSettingStruct `json:"indexSettings"`
}

SearchRelevancyStruct struct for settings request

func GetSearchRelevancySettingFromCache

func GetSearchRelevancySettingFromCache(indexName string) (SearchRelevancyStruct, error)

GetSearchRelevancySettingFromCache to get a setting from cache

type SearchStruct

type SearchStruct struct {
	DataField       []string                                `json:"dataField"`
	FieldWeights    []interface{}                           `json:"fieldWeights"` // allow string array with single decimal place value to fix [mapper [search.fieldWeights] cannot be changed from type [float] to [long] [type=illegal_argument_exception]] eg. "1.0"
	SearchOperators bool                                    `json:"searchOperators"`
	QueryString     bool                                    `json:"queryString"`
	Fuzziness       interface{}                             `json:"fuzziness,omitempty"` // string or int
	QueryFormat     *string                                 `json:"queryFormat"`
	RankFeature     *map[string]querytranslate.RankFunction `json:"rankFeature,omitempty"`
	DistinctField   string                                  `json:"distinctField,omitempty"`
}

SearchStruct search settings struct

type SortOption

type SortOption struct {
	Label     string `json:"label"`
	DataField string `json:"dataField"`
	SortBy    string `json:"sortBy"`
}

type SynonymsStruct

type SynonymsStruct struct {
	Enabled bool `json:"enabled"`
}

SynonymsStruct synonym settings struct

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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