suggestions

package
v3.31.1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoolOrStringArray added in v3.24.0

type BoolOrStringArray struct {
	IsBool      bool
	Bool        bool
	StringArray []string
}

BoolOrStringArray can hold either a bool or a []string. IsBool indicates the valid value: Bool or StringArray.

func NewBool added in v3.24.0

func NewBool(boolValue bool) BoolOrStringArray

func NewStringArray added in v3.24.0

func NewStringArray(array []string) BoolOrStringArray

func (BoolOrStringArray) MarshalJSON added in v3.24.0

func (b BoolOrStringArray) MarshalJSON() ([]byte, error)

MarshalJSON encodes a BoolOrStringArray to a JSON bool or string array.

func (*BoolOrStringArray) UnmarshalJSON added in v3.24.0

func (b *BoolOrStringArray) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes a JSON bool or string array into a BoolOrStringArray.

type Client

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

Client provides methods to interact with the Algolia Query Suggestions API.

func NewClient

func NewClient(appID, apiKey string) *Client

NewClient instantiates a new client able to interact with the Algolia Query Suggestions API.

func NewClientWithConfig

func NewClientWithConfig(config Configuration) *Client

NewClientWithConfig instantiates a new client able to interact with the Algolia Query Suggestions API.

func (*Client) CreateConfig

func (c *Client) CreateConfig(config IndexConfiguration, opts ...interface{}) error

CreateConfig creates new query suggestions index with given config.

func (*Client) DeleteConfig

func (c *Client) DeleteConfig(indexName string, opts ...interface{}) error

DeleteConfig deletes the query suggestions index config.

func (*Client) GetConfig

func (c *Client) GetConfig(indexName string, opts ...interface{}) (config *IndexConfiguration, err error)

GetConfig retrieves the query suggestions index config by the given indexName.

func (*Client) ListConfigs

func (c *Client) ListConfigs(opts ...interface{}) (configs []*IndexConfiguration, err error)

ListConfigs lists all the configs of the query suggestions in a single call.

func (*Client) UpdateConfig

func (c *Client) UpdateConfig(config IndexConfiguration, opts ...interface{}) error

UpdateConfig updates the query suggestions index config.

type Configuration

type Configuration struct {
	AppID          string
	APIKey         string
	Hosts          []string
	Requester      transport.Requester
	ReadTimeout    time.Duration
	WriteTimeout   time.Duration
	Region         region.Region
	Headers        map[string]string
	ExtraUserAgent string
}

Configuration contains all the different parameters one can change to instantiate a new client for the Query Suggestions API.

type IndexConfiguration

type IndexConfiguration struct {
	// Index name to target.
	IndexName string `json:"indexName"`
	// List of source indices used to generate a Query Suggestions index.
	SourceIndices []SourceIndex `json:"sourceIndices"`
	// De-duplicate singular and plural suggestions. Can be either a list languages []string or a boolean.
	// true value means that all the languages are supported.
	// false value means that singulars and plurals are not considered the same for matching purposes (foot will not find feet).
	// []string a list of language ISO codes for which singular and plural suggestions should be enabled.
	Languages BoolOrStringArray `json:"languages"`
	// List of words and patterns to exclude from the Query Suggestions index.
	Exclude []string `json:"exclude,omitempty"`
}

type SourceIndex

type SourceIndex struct {
	// Source index name.
	IndexName string `json:"indexName"`
	// List of analytics tags to filter the popular searches per tag.
	AnalyticsTags []string `json:"analyticsTags,omitempty"`
	// List of facets to define as categories for the query suggestions
	Facets []map[string]interface{}
	// Minimum number of hits (e.g., matching records in the source index) to generate a suggestions.
	MinHits *int `json:"minHits"`
	// Minimum number of required letters for a suggestion to remain.
	MinLetters *int `json:"minLetters"`
	// List of facet attributes used to generate Query Suggestions. The resulting suggestions are every combination of the facets in the nested list
	Generate [][]string `json:"generate,omitempty"`
	// List of external indices to use to generate custom Query Suggestions.
	External []string `json:"external,omitempty"`
}

Jump to

Keyboard shortcuts

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