suggestions

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: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NumberOfDays = 30
)

Variables

This section is empty.

Functions

func ApplySuggestionsPreferences

func ApplySuggestionsPreferences(requestQuery querytranslate.RSQuery, preferences *Preferences) (isApplied bool)

func Contains

func Contains(a []string, x string) bool

Contains tells whether a contains x.

func GenerateDocumentSuggestionsQuery

func GenerateDocumentSuggestionsQuery(q querytranslate.Query, value string, config querytranslate.RecentDocumentSuggestionsOptions, userId string, indices []string) (*es7.SearchService, *es7.BoolQuery)

GenerateDocumentSuggestionsQuery will generate the document suggestions query based on the input values and accordingly return the built query

func Instance

func Instance() *suggestions

Use only this function to fetch the instance of suggestions from within this package to avoid creating stateless duplicates of the plugin.

func SetIndexPreferences

func SetIndexPreferences(pref IndexPreferences)

Sets the index preferences

func SetPopularPreferences

func SetPopularPreferences(pref PopularPreferences)

Sets the popular preferences

func SetRecentPreferences

func SetRecentPreferences(pref RecentPreferences)

Sets the recent preferences

Types

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 Error

type Error struct {
	Code  int
	Error error
}

func ApplySuggestions

func ApplySuggestions(
	requestQuery querytranslate.RSQuery,
	originalResponse []byte,
	recentSuggestionsMap map[string]SuggestionOutput,
	popularSuggestionsMap map[string]SuggestionOutput,
	featuredSuggestionsMap map[string]SuggestionOutput,
	faqSuggestionsMap map[string]SuggestionOutput,
	documentSuggestionsMap map[string]SuggestionOutput,
) ([]byte, *Error)

func GetDocumentSuggestions

func GetDocumentSuggestions(q querytranslate.Query, value string, config querytranslate.RecentDocumentSuggestionsOptions, userId string, indices []string) ([]querytranslate.SuggestionHIT, *Error)

GetDocumentSuggestions will get the document suggestions based on the current user.

func GetFAQSuggestions

func GetFAQSuggestions(config querytranslate.FAQSuggestionsOptions, value string, searchboxId *string) ([]querytranslate.SuggestionHIT, *Error)

GetFAQSuggestions will return the FAQ suggestions based on the passed value

func GetPopularSuggestions

func GetPopularSuggestions(config querytranslate.PopularSuggestionsOptions, value string, indices []string) ([]querytranslate.SuggestionHIT, *Error)

To get popular suggestions

func GetRecentSuggestions

To get recent suggestions

type ExternalSuggestion

type ExternalSuggestion struct {
	Key          string                   `json:"key"`
	Count        *int64                   `json:"count"`
	Indices      []string                 `json:"indices"`
	Meta         map[string]interface{}   `json:"meta,omitempty"`
	CustomEvents map[string][]interface{} `json:"customEvents,omitempty"`
}

Custom external suggestions

type IndexPreferences

type IndexPreferences struct {
	Indices                     []string `json:"indices"`
	ShowDistinctSuggestions     *bool    `json:"showDistinctSuggestions"`
	EnablePredictiveSuggestions *bool    `json:"enablePredictiveSuggestions"`
	MaxPredictedWords           *int     `json:"maxPredictedWords"`
	Size                        *int     `json:"size"`
	ApplyStopwords              *bool    `json:"applyStopwords"`
	CustomStopwords             []string `json:"customStopwords"`
	EnableSynonyms              *bool    `json:"enableSynonyms"`
	IncludeFields               []string `json:"includeFields"`
	ExcludeFields               []string `json:"excludeFields"`
	CategoryField               *string  `json:"categoryField"`
	URLField                    *string  `json:"urlField"`
	CustomQuery                 *string  `json:"customQuery"`
}

preferences for index type of suggestions

func GetIndexPreferences

func GetIndexPreferences() IndexPreferences

To get the index preferences

type PopularPreferences

type PopularPreferences struct {
	Size                int                  `json:"size"`
	MinCount            int64                `json:"minCount"`
	MinChars            int64                `json:"minChars"`
	MinHits             int64                `json:"minHits"`
	NumberOfDays        int64                `json:"numberOfDays"`
	Blacklist           []string             `json:"blacklist"`
	Indices             []string             `json:"indices"`
	ExternalSuggestions []ExternalSuggestion `json:"externalSuggestions"`
	TransformDiacritics bool                 `json:"transformDiacritics"`
	LastSyncTime        int64                `json:"lastSyncedTime"`
	AliasToIndex        string               `json:"aliasToIndex"`
}

preferences for popular type of suggestions

func GetPopularPreferences

func GetPopularPreferences() PopularPreferences

To get the popular preferences

type Preferences

type Preferences struct {
	Index   IndexPreferences   `json:"index"`
	Popular PopularPreferences `json:"popular"`
	Recent  RecentPreferences  `json:"recent"`
}

type RecentPreferences

type RecentPreferences struct {
	Indices  []string `json:"indices"`
	MinHits  *int     `json:"minHits"`
	MinChars *int     `json:"minChars"`
	Size     *int     `json:"size"`
}

preferences for recent type of suggestions

func GetRecentPreferences

func GetRecentPreferences() RecentPreferences

To get the recent preferences

type Suggestion

type Suggestion struct {
	ID           string                   `json:"id"`
	Key          string                   `json:"key"`
	Count        *int64                   `json:"count"`
	Indices      []string                 `json:"indices"`
	Meta         map[string]interface{}   `json:"meta,omitempty"`
	QueryLength  *int                     `json:"search_characters_length,omitempty"`
	CustomEvents map[string][]interface{} `json:"customEvents,omitempty"`
}

type SuggestionOutput

type SuggestionOutput struct {
	QueryID     string
	Suggestions []querytranslate.SuggestionHIT
	Error       *Error
}

type SuggestionsPreferencesMigration

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

func (SuggestionsPreferencesMigration) ConditionCheck

func (m SuggestionsPreferencesMigration) ConditionCheck() (bool, *util.Error)

func (SuggestionsPreferencesMigration) IsAsync

func (SuggestionsPreferencesMigration) Script

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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