search

package
v3.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2019 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultMaxBatchSize defines the default maximum batch size to be used to
	// automatically split record batches when using Index.SaveObjects.
	DefaultMaxBatchSize = 1000
)

Variables

This section is empty.

Functions

func GenerateSecuredAPIKey

func GenerateSecuredAPIKey(apiKey string, opts ...interface{}) (string, error)

GenerateSecuredAPIKey generates a public API key intended to restrict access to certain records. This new key is built upon the existing key named `apiKey` and the following options:

  • opt.Filters (string of filters to apply automatically on search queries)
  • opt.Referers (string slice of allowed referers)
  • opt.RestrictIndices (comma-separated string list of the indices to restrict)
  • opt.RestrictSources (string of the allowed IPv4 network)
  • opt.UserToken (string identifier generally used to rate-limit users per IP)
  • opt.ValidUntil (timestamp of the expiration date)

More details here: https://www.algolia.com/doc/api-reference/api-methods/generate-secured-api-key/?language=python#parameters

Types

type Account

type Account struct{}

Account provides methods to interact with the Algolia Search API on multiple indices which belong to different Algolia applications.

func NewAccount

func NewAccount() *Account

NewAccount instantiates a new account able to interact with the Algolia Search API on multiple indices which belong to different Algolia applications.

func (*Account) CopyIndex

func (a *Account) CopyIndex(src, dst *Index, opts ...interface{}) (*wait.Group, error)

CopyIndex copies the full content (objects, synonyms, rules, settings) of the given src index into the dst one. This method can only be used with indices which belong to different Algolia applications. To perform the same operation on indices which belong to the same Algolia application, use Client.CopyIndex which is optimized for this use-case.

type AltCorrection1

type AltCorrection1 struct {
	Word        string
	Corrections []string
	// contains filtered or unexported fields
}

func NewAltCorrection1

func NewAltCorrection1(objectID, word string, corrections ...string) AltCorrection1

func (AltCorrection1) MarshalJSON

func (s AltCorrection1) MarshalJSON() ([]byte, error)

func (AltCorrection1) ObjectID

func (s AltCorrection1) ObjectID() string

func (AltCorrection1) Type

func (s AltCorrection1) Type() SynonymType

func (*AltCorrection1) UnmarshalJSON

func (s *AltCorrection1) UnmarshalJSON(data []byte) error

type AltCorrection2

type AltCorrection2 AltCorrection1

func NewAltCorrection2

func NewAltCorrection2(objectID, word string, corrections ...string) AltCorrection2

func (AltCorrection2) MarshalJSON

func (s AltCorrection2) MarshalJSON() ([]byte, error)

func (AltCorrection2) ObjectID

func (s AltCorrection2) ObjectID() string

func (AltCorrection2) Type

func (s AltCorrection2) Type() SynonymType

func (*AltCorrection2) UnmarshalJSON

func (s *AltCorrection2) UnmarshalJSON(data []byte) error

type Alternatives

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

func AlternativesDisabled

func AlternativesDisabled() *Alternatives

func AlternativesEnabled

func AlternativesEnabled() *Alternatives

func (Alternatives) MarshalJSON

func (a Alternatives) MarshalJSON() ([]byte, error)

func (*Alternatives) UnmarshalJSON

func (a *Alternatives) UnmarshalJSON(data []byte) error

type AppliedRule

type AppliedRule struct {
	ObjectID string `json:"objectID"`
}

type AssignUserIDRes

type AssignUserIDRes struct {
	CreatedAt string `json:"createdAt"`
}

type AutomaticFacetFilter

type AutomaticFacetFilter struct {
	Facet       string `json:"facet"`
	Disjunctive bool   `json:"disjunctive"` // Defaults to false
	Score       int    `json:"score"`       // Defaults to 1
}

type BatchAction

type BatchAction string
const (
	AddObject                   BatchAction = "addObject"
	UpdateObject                BatchAction = "updateObject"
	PartialUpdateObject         BatchAction = "partialUpdateObject"
	PartialUpdateObjectNoCreate BatchAction = "partialUpdateObjectNoCreate"
	DeleteObject                BatchAction = "deleteObject"
	Delete                      BatchAction = "delete"
	Clear                       BatchAction = "clear"
)

type BatchOperation

type BatchOperation struct {
	Action BatchAction `json:"action"`
	Body   interface{} `json:"body,omitempty"`
}

type BatchOperationIndexed

type BatchOperationIndexed struct {
	BatchOperation
	IndexName string `json:"indexName"`
}

type BatchRes

type BatchRes struct {
	ObjectIDs []string `json:"objectIDs"`
	TaskID    int      `json:"taskID"`
	// contains filtered or unexported fields
}

func (BatchRes) Wait

func (r BatchRes) Wait() error

type Client

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

Client provides methods to interact with the Algolia Search API on multiple indices which belong to the same Algolia application.

func NewClient

func NewClient(appID, apiKey string) *Client

NewClient instantiates a new client able to interact with the Algolia Search API on multiple indices which belong to the same Algolia application.

func NewClientWithConfig

func NewClientWithConfig(config Configuration) *Client

NewClientWithConfig instantiates a new client able to interact with the Algolia Search API on multiple indices which belong to the same Algolia application.

func (*Client) AddAPIKey

func (c *Client) AddAPIKey(key Key, opts ...interface{}) (res CreateKeyRes, err error)

AddAPIKey creates a new API key. Once created, the key can be referenced by other methods via the Key field of the response which represents its keyID.

func (*Client) AssignUserID

func (c *Client) AssignUserID(userID, clusterName string, opts ...interface{}) (res AssignUserIDRes, err error)

AssignUserID assign the given userID to the given cluster.

func (*Client) CopyIndex

func (c *Client) CopyIndex(source, destination string, opts ...interface{}) (UpdateTaskRes, error)

CopyIndex copies the full content (objects, synonyms, rules, settings) of the given source index into the destination one.

This method can only be used with indices which belong to the same Algolia application. To perform the same operation on indices which belong to different Algolia applications, use Account.CopyIndex which is optimized for this use-case.

func (*Client) CopyRules

func (c *Client) CopyRules(source, destination string, opts ...interface{}) (UpdateTaskRes, error)

CopyRules copies the rules from the given source index into the destination one.

This method can only be used with indices which belong to the same Algolia application.

func (*Client) CopySettings

func (c *Client) CopySettings(source, destination string, opts ...interface{}) (UpdateTaskRes, error)

CopySettings copies the settings from the given source index into the destination one.

This method can only be used with indices which belong to the same Algolia application.

func (*Client) CopySynonyms

func (c *Client) CopySynonyms(source, destination string, opts ...interface{}) (UpdateTaskRes, error)

CopySynonyms copies the synonyms from the given source index into the destination one.

This method can only be used with indices which belong to the same Algolia application.

func (*Client) CustomRequest

func (c *Client) CustomRequest(
	res interface{},
	method string,
	path string,
	body interface{},
	k call.Kind,
	opts ...interface{},
) error

CustomRequest is a low-level function which build a request from the given parameters and send it through the requester, making use of the underlying retry strategy.

func (*Client) DeleteAPIKey

func (c *Client) DeleteAPIKey(keyID string, opts ...interface{}) (res DeleteKeyRes, err error)

DeleteAPIKey deletes the API key for the given keyID.

To restore a deleted key, you can use RestoreAPIKey with the same keyID.

func (*Client) GetAPIKey

func (c *Client) GetAPIKey(keyID string, opts ...interface{}) (key Key, err error)

GetAPIKey retrieves the API key identified by the given keyID.

func (*Client) GetLogs

func (c *Client) GetLogs(opts ...interface{}) (res GetLogsRes, err error)

GetLogs returns the most recent information logs of the Algolia application.

func (*Client) GetPersonalizationStrategy

func (c *Client) GetPersonalizationStrategy(opts ...interface{}) (res GetPersonalizationStrategyRes, err error)

GetPersonalizationStrategy retrieves the full configuration of the personalization strategy feature.

func (*Client) GetTopUserIDs

func (c *Client) GetTopUserIDs(opts ...interface{}) (res TopUserIDs, err error)

GetTopUserIDs retrieves the top list of userIDs managed by MCM.

func (*Client) GetUserID

func (c *Client) GetUserID(userID string, opts ...interface{}) (res UserID, err error)

GetUserID retrieves the user, managed by MCM, according to the given userID.

func (*Client) InitIndex

func (c *Client) InitIndex(indexName string) *Index

InitIndex instantiates a new index able to interact with the Algolia Search API on a single index.

func (*Client) ListAPIKeys

func (c *Client) ListAPIKeys(opts ...interface{}) (res ListAPIKeysRes, err error)

ListAPIKeys list all the API keys of the application.

func (*Client) ListClusters

func (c *Client) ListClusters(opts ...interface{}) (res ListClustersRes, err error)

ListClusters list all the clusters managed by MCM.

func (*Client) ListIndices

func (c *Client) ListIndices(opts ...interface{}) (res ListIndicesRes, err error)

ListIndices lists all the indices of the Algolia application in a single call.

func (*Client) ListUserIDs

func (c *Client) ListUserIDs(opts ...interface{}) (res ListUserIDsRes, err error)

ListUserIDs list all the userIDs managed by MCM.

Pagination can be implemented using the opt.Page and opt.HitsPerPage option parameters.

func (*Client) MoveIndex

func (c *Client) MoveIndex(source, destination string, opts ...interface{}) (UpdateTaskRes, error)

MoveIndex moves the full content (objects, synonyms, rules, settings) of the given source index into the destination one, effectively deleting the source index.

func (*Client) MultipleBatch

func (c *Client) MultipleBatch(operations []BatchOperationIndexed, opts ...interface{}) (res MultipleBatchRes, err error)

MultipleBatch applies multiple indexing operations on potentially multiple indices in a single call.

func (*Client) MultipleGetObjects

func (c *Client) MultipleGetObjects(requests []IndexedGetObject, objects interface{}, opts ...interface{}) (err error)

MultipleGetObjects retrieves multiple objects from potentially multiple indices in a single call.

func (*Client) MultipleQueries

func (c *Client) MultipleQueries(queries []IndexedQuery, strategy string, opts ...interface{}) (res MultipleQueriesRes, err error)

MultipleQueries performs multiple search queries on potentially multiple indices in a single call.

func (*Client) RemoveUserID

func (c *Client) RemoveUserID(userID string, opts ...interface{}) (res RemoveUserIDRes, err error)

RemoveUserID deletes the given userID managed by MCM.

func (*Client) RestoreAPIKey

func (c *Client) RestoreAPIKey(keyID string, opts ...interface{}) (res RestoreKeyRes, err error)

RestoreAPIKey restores the API key for the given keyID if it ever existed.

func (*Client) SearchUserIDs

func (c *Client) SearchUserIDs(query string, opts ...interface{}) (res SearchUserIDRes, err error)

func (*Client) SetPersonalizationStrategy

func (c *Client) SetPersonalizationStrategy(strategy Strategy, opts ...interface{}) (res SetPersonalizationStrategyRes, err error)

SetPersonalizationStrategy defines and override the full configuration of the personalization strategy feature.

func (*Client) UpdateAPIKey

func (c *Client) UpdateAPIKey(key Key, opts ...interface{}) (res UpdateKeyRes, err error)

UpdateAPIKey updates the API key identified by its Value field and updates all its non-zero fields.

type ClientInterface

type ClientInterface interface {
	// Misc
	InitIndex(indexName string) *Index
	ListIndices(opts ...interface{}) (res ListIndicesRes, err error)
	GetLogs(opts ...interface{}) (res GetLogsRes, err error)
	CustomRequest(res interface{}, method string, path string, body interface{}, k call.Kind, opts ...interface{}) error

	// Copy index operations
	CopyRules(source, destination string, opts ...interface{}) (UpdateTaskRes, error)
	CopySettings(source, destination string, opts ...interface{}) (UpdateTaskRes, error)
	CopySynonyms(source, destination string, opts ...interface{}) (UpdateTaskRes, error)
	CopyIndex(source, destination string, opts ...interface{}) (UpdateTaskRes, error)

	// Move index operations
	MoveIndex(source, destination string, opts ...interface{}) (UpdateTaskRes, error)

	// API key methods
	GetAPIKey(keyID string, opts ...interface{}) (key Key, err error)
	AddAPIKey(key Key, opts ...interface{}) (res CreateKeyRes, err error)
	UpdateAPIKey(key Key, opts ...interface{}) (res UpdateKeyRes, err error)
	DeleteAPIKey(keyID string, opts ...interface{}) (res DeleteKeyRes, err error)
	RestoreAPIKey(keyID string, opts ...interface{}) (res RestoreKeyRes, err error)
	ListAPIKeys(opts ...interface{}) (res ListAPIKeysRes, err error)

	// Multiple methods
	MultipleBatch(operations []BatchOperationIndexed, opts ...interface{}) (res MultipleBatchRes, err error)
	MultipleGetObjects(requests []IndexedGetObject, objects interface{}, opts ...interface{}) (err error)
	MultipleQueries(queries []IndexedQuery, strategy string, opts ...interface{}) (res MultipleQueriesRes, err error)

	// Multi-Cluster Management (MCM) methods
	ListClusters(opts ...interface{}) (res ListClustersRes, err error)
	ListUserIDs(opts ...interface{}) (res ListUserIDsRes, err error)
	GetUserID(userID string, opts ...interface{}) (res UserID, err error)
	AssignUserID(userID, clusterName string, opts ...interface{}) (res AssignUserIDRes, err error)
	RemoveUserID(userID string, opts ...interface{}) (res RemoveUserIDRes, err error)
	GetTopUserIDs(opts ...interface{}) (res TopUserIDs, err error)
	SearchUserIDs(query string, opts ...interface{}) (res SearchUserIDRes, err error)

	// Personalization
	SetPersonalizationStrategy(strategy Strategy, opts ...interface{}) (res SetPersonalizationStrategyRes, err error)
	GetPersonalizationStrategy(opts ...interface{}) (res GetPersonalizationStrategyRes, err error)
}

type Cluster

type Cluster struct {
	ClusterName string `json:"clusterName"`
	NbRecords   int    `json:"nbRecords"`
	NbUserIDs   int    `json:"nbUserIDs"`
	DataSize    int    `json:"dataSize"`
}

type Configuration

type Configuration struct {
	AppID          string
	APIKey         string
	Hosts          []string
	MaxBatchSize   int
	Requester      transport.Requester
	ReadTimeout    time.Duration
	WriteTimeout   time.Duration
	Headers        map[string]string
	ExtraUserAgent string
	Compression    compression.Compression
}

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

type CreateKeyRes

type CreateKeyRes struct {
	Key       string    `json:"key"`
	CreatedAt time.Time `json:"createdAt"`
	// contains filtered or unexported fields
}

func (CreateKeyRes) Wait

func (r CreateKeyRes) Wait() error

type DeleteKeyRes

type DeleteKeyRes struct {
	DeletedAt time.Time `json:"deletedAt"`
	// contains filtered or unexported fields
}

func (DeleteKeyRes) Wait

func (r DeleteKeyRes) Wait() error

type DeleteTaskRes

type DeleteTaskRes struct {
	DeletedAt time.Time `json:"deletedAt"`
	TaskID    int       `json:"taskID"`
	// contains filtered or unexported fields
}

func (DeleteTaskRes) Wait

func (r DeleteTaskRes) Wait() error

type EventsScoring

type EventsScoring struct {
	Score int    `json:"score"`
	Type  string `json:"type"`
}

type FacetHit

type FacetHit struct {
	Value       string `json:"value"`
	Highlighted string `json:"highlighted"`
	Count       int    `json:"count"`
}

type FacetStat

type FacetStat struct {
	Min float64 `json:"min"`
	Max float64 `json:"max"`
	Avg float64 `json:"avg"`
	Sum float64 `json:"sum"`
}

type FacetsScoring

type FacetsScoring struct {
	Score int `json:"score"`
}

type GetLogsRes

type GetLogsRes struct {
	Logs []LogRes `json:"logs"`
}

type GetPersonalizationStrategyRes

type GetPersonalizationStrategyRes struct {
	TaskID int `json:"taskID"`
	Strategy
}

type GroupBatchRes

type GroupBatchRes struct {
	Responses []BatchRes
}

func (GroupBatchRes) ObjectIDs

func (r GroupBatchRes) ObjectIDs() []string

func (GroupBatchRes) Wait

func (r GroupBatchRes) Wait() error

type HiddenObject

type HiddenObject struct {
	ObjectID string `json:"objectID"`
}

type HighlightResult

type HighlightResult map[string]HighlightedResult

type HighlightedResult

type HighlightedResult struct {
	FullyHighlighted bool     `json:"fullyHighlighted"`
	MatchedWords     []string `json:"matchedWords"`
	MatchLevel       string   `json:"matchLevel"`
	Value            string   `json:"value"`
}

type Index

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

Index provides methods to interact with the Algolia Search API on a single index.

func (*Index) Batch

func (i *Index) Batch(operations []BatchOperation, opts ...interface{}) (res BatchRes, err error)

Batch sends all the given indexing operations with a single call.

func (*Index) BrowseObjects

func (i *Index) BrowseObjects(opts ...interface{}) (*ObjectIterator, error)

BrowseObjects returns an iterator which will retrieve records one by one from the index according to the given query parameters.

The return ObjectIterator can decode objects by passing the address of the object to decode to as a first argument of its Next() method.

func (*Index) BrowseRules

func (i *Index) BrowseRules(opts ...interface{}) (*RuleIterator, error)

BrowseRules returns an iterator which will retrieve rules one by one from the index.

func (*Index) BrowseSynonyms

func (i *Index) BrowseSynonyms(opts ...interface{}) (*SynonymIterator, error)

BrowseSynonyms returns an iterator which will retrieve synonyms one by one from the index.

func (*Index) ClearObjects

func (i *Index) ClearObjects(opts ...interface{}) (res UpdateTaskRes, err error)

ClearObjects deletes all the records of the index.

func (*Index) ClearRules

func (i *Index) ClearRules(opts ...interface{}) (res UpdateTaskRes, err error)

ClearRules removes all the rules from the index.

func (*Index) ClearSynonyms

func (i *Index) ClearSynonyms(opts ...interface{}) (res UpdateTaskRes, err error)

ClearSynonyms removes all the synonyms from the index.

func (*Index) Delete

func (i *Index) Delete(opts ...interface{}) (res DeleteTaskRes, err error)

Delete removes the entire index. After this call, new indexing calls can be sent with the same index instance.

func (*Index) DeleteBy

func (i *Index) DeleteBy(opts ...interface{}) (res UpdateTaskRes, err error)

DeleteBy removes all the records that match the given query parameters.

Not all query parameters are supported, please refer to the official documentation for an exhaustive list: https://www.algolia.com/doc/api-reference/api-methods/delete-by/#method-param-filterparameters

func (*Index) DeleteObject

func (i *Index) DeleteObject(objectID string, opts ...interface{}) (res DeleteTaskRes, err error)

DeleteObject removes the record identified by the given objectID.

func (*Index) DeleteObjects

func (i *Index) DeleteObjects(objectIDs []string, opts ...interface{}) (res BatchRes, err error)

DeleteObjects removes the records identified by the given objectIDs.

func (*Index) DeleteRule

func (i *Index) DeleteRule(objectID string, opts ...interface{}) (res UpdateTaskRes, err error)

DeleteRule removes the rule identified by the given objectID.

func (*Index) DeleteSynonym

func (i *Index) DeleteSynonym(objectID string, opts ...interface{}) (res DeleteTaskRes, err error)

DeleteSynonym removes the synonym identified by the given objectID.

func (*Index) Exists

func (i *Index) Exists() (bool, error)

Exists returns whether an initialized index exists or not, along with a nil error. When encountering a network error, a non-nil error is returned along with false.

func (*Index) FindFirstObject deprecated

func (i *Index) FindFirstObject(
	filterFunc func(object map[string]interface{}) bool,
	query string,
	doNotPaginate bool,
	opts ...interface{},
) (*ObjectWithPosition, error)

FindFirstObject does the same as FindObject except that it reverse the doNotPaginate boolean parameter.

Deprecated: Use FindObject instead.

func (*Index) FindObject

func (i *Index) FindObject(
	filterFunc func(object map[string]interface{}) bool,
	query string,
	paginate bool,
	opts ...interface{},
) (*ObjectWithPosition, error)

FindObject searches iteratively through the search response `Hits` field to find the first response hit that would match against the given `filterFunc` function.

If no object has been found within the first result set, the function will perform a new search operation on the next page of results, if any, until a matching object is found or the end of results, whichever happens first.

To prevent the iteration through pages of results, `doNotPaginate` parameter can be set to true. This will stop the function at the end of the first page of search results even if no object does match.

func (*Index) GetAppID

func (i *Index) GetAppID() string

GetAppID returns the Algolia application ID on where the current index leaves.

func (*Index) GetObject

func (i *Index) GetObject(objectID string, object interface{}, opts ...interface{}) error

GetObject retrieves the record identified by the given objectID and deserializes it into the object parameter.

func (*Index) GetObjects

func (i *Index) GetObjects(objectIDs []string, objects interface{}, opts ...interface{}) error

GetObjects retrieves the records identified by the given objectIDs and deserializes them into the objects parameter.

func (*Index) GetRule

func (i *Index) GetRule(objectID string, opts ...interface{}) (rule Rule, err error)

GetRule retrieves the rule identified by the given objectID.

func (*Index) GetSettings

func (i *Index) GetSettings(opts ...interface{}) (settings Settings, err error)

GetSettings retrieves the settings of the index.

func (*Index) GetStatus

func (i *Index) GetStatus(taskID int) (res TaskStatusRes, err error)

GetStatus retrieves the task status according to the Algolia engine for the given task.

func (*Index) GetSynonym

func (i *Index) GetSynonym(objectID string, opts ...interface{}) (synonym Synonym, err error)

GetSynonym retrieves the synonym identified by the given objectID.

func (*Index) PartialUpdateObject

func (i *Index) PartialUpdateObject(object interface{}, opts ...interface{}) (res UpdateTaskRes, err error)

PartialUpdateObject replaces the object content of the given object according to its respective objectID field.

func (*Index) PartialUpdateObjects

func (i *Index) PartialUpdateObjects(objects interface{}, opts ...interface{}) (res GroupBatchRes, err error)

PartialUpdateObjects replaces object content of all the given objects according to their respective objectID field.

If opt.CreateIfNotExists(true) is passed, non-existing objects will be created, otherwise, the call will fail.

This method does not send all the provided objects in a single call. Objects are sent by batches whose size is controlled by Configuration.MaxBatchSize (defaults to search.DefaultMaxBatchSize).

func (*Index) ReplaceAllObjects

func (i *Index) ReplaceAllObjects(objects interface{}, opts ...interface{}) (g *wait.Group, err error)

ReplaceAllObjects saves all the given objects into the index by replacing all the original objects. Settings, rules and synonyms are preserved.

Because this method is performing all operations in a non-blocking way, it may be fast but Wait() needs to be called on the returned wait.Group to ensure completion.

In rare cases, this operation may fail in case of network disconnections. To prevent issues, one may want to pass the opt.Safe(true) option. Note that passing this option will make the method blocking.

func (*Index) ReplaceAllRules

func (i *Index) ReplaceAllRules(rules []Rule, opts ...interface{}) (UpdateTaskRes, error)

ReplaceAllRules replaces any existing rules with the given ones.

func (*Index) ReplaceAllSynonyms

func (i *Index) ReplaceAllSynonyms(synonyms []Synonym, opts ...interface{}) (UpdateTaskRes, error)

ReplaceAllSynonyms replaces any existing synonyms with the given ones.

func (*Index) SaveObject

func (i *Index) SaveObject(object interface{}, opts ...interface{}) (res SaveObjectRes, err error)

SaveObject saves the given object to the index.

func (*Index) SaveObjects

func (i *Index) SaveObjects(objects interface{}, opts ...interface{}) (res GroupBatchRes, err error)

SaveObjects saves the given objects to the index.

Objects can either be a slice, an array or an object implementing the iterator.Iterator interface. In the last case, SaveObjects will call the Next method of the iterator to retrieve the objects sent one by one.

This method does not send all the provided objects in a single call. Objects are sent by batches whose size is controlled by Configuration.MaxBatchSize (defaults to search.DefaultMaxBatchSize).

func (*Index) SaveRule

func (i *Index) SaveRule(rule Rule, opts ...interface{}) (res UpdateTaskRes, err error)

SaveRule saves the given rule.

func (*Index) SaveRules

func (i *Index) SaveRules(rules []Rule, opts ...interface{}) (res UpdateTaskRes, err error)

SaveRule saves the given rules.

Unlike SaveObjects, this method does not batch the given rules i.e. all rules are sent in a single call.

func (*Index) SaveSynonym

func (i *Index) SaveSynonym(synonym Synonym, opts ...interface{}) (res UpdateTaskRes, err error)

SaveSynonym saves the given synonym.

func (*Index) SaveSynonyms

func (i *Index) SaveSynonyms(synonyms []Synonym, opts ...interface{}) (res UpdateTaskRes, err error)

SaveSynonym saves the given synonyms.

Unlike SaveObjects, this method does not batch the given synonyms i.e. all synonyms are sent in a single call.

func (*Index) Search

func (i *Index) Search(query string, opts ...interface{}) (res QueryRes, err error)

Search performs a search query according to the given query string and any given query parameter among all the index records.

func (*Index) SearchForFacetValues

func (i *Index) SearchForFacetValues(facet, query string, opts ...interface{}) (res SearchForFacetValuesRes, err error)

SearchForFacetValues performs a search query according to the given query string and any given parameter among the values of the given facet.

func (*Index) SearchRules

func (i *Index) SearchRules(query string, opts ...interface{}) (res SearchRulesRes, err error)

SearchRules search for rules according to the given query string and any rule parameter, as documented here: https://www.algolia.com/doc/api-reference/api-methods/search-rules/

func (*Index) SearchSynonyms

func (i *Index) SearchSynonyms(query string, opts ...interface{}) (res SearchSynonymsRes, err error)

SearchSynonyms search for synonyms according to the given query string and any synonym parameter, as documented here: https://www.algolia.com/doc/api-reference/api-methods/search-synonyms/

func (*Index) SetSettings

func (i *Index) SetSettings(settings Settings, opts ...interface{}) (res UpdateTaskRes, err error)

SetSettings applies all the non-nil Settings field to the settings configuration of the index.

func (*Index) WaitTask

func (i *Index) WaitTask(taskID int) error

WaitTask blocks until the task identified by the given taskID is completed on Algolia engine.

type IndexInterface

type IndexInterface interface {
	// Misc
	WaitTask(taskID int) error
	GetStatus(taskID int) (res TaskStatusRes, err error)
	GetAppID() string
	ClearObjects(opts ...interface{}) (res UpdateTaskRes, err error)
	Delete(opts ...interface{}) (res DeleteTaskRes, err error)
	Exists() (exists bool, err error)

	// Indexing
	GetObject(objectID string, object interface{}, opts ...interface{}) error
	GetObjects(objectIDs []string, objects interface{}, opts ...interface{}) error
	SaveObject(object interface{}, opts ...interface{}) (res SaveObjectRes, err error)
	SaveObjects(objects interface{}, opts ...interface{}) (res GroupBatchRes, err error)
	PartialUpdateObject(object interface{}, opts ...interface{}) (res UpdateTaskRes, err error)
	PartialUpdateObjects(objects interface{}, opts ...interface{}) (res GroupBatchRes, err error)
	DeleteObject(objectID string, opts ...interface{}) (res DeleteTaskRes, err error)
	DeleteObjects(objectIDs []string, opts ...interface{}) (res BatchRes, err error)
	DeleteBy(opts ...interface{}) (res UpdateTaskRes, err error)
	Batch(operations []BatchOperation, opts ...interface{}) (res BatchRes, err error)

	// Query rules
	GetRule(objectID string, opts ...interface{}) (rule Rule, err error)
	SaveRule(rule Rule, opts ...interface{}) (res UpdateTaskRes, err error)
	SaveRules(rules []Rule, opts ...interface{}) (res UpdateTaskRes, err error)
	ClearRules(opts ...interface{}) (res UpdateTaskRes, err error)
	DeleteRule(objectID string, opts ...interface{}) (res UpdateTaskRes, err error)

	// Synonyms
	GetSynonym(objectID string, opts ...interface{}) (synonym Synonym, err error)
	SaveSynonym(synonym Synonym, opts ...interface{}) (res UpdateTaskRes, err error)
	SaveSynonyms(synonyms []Synonym, opts ...interface{}) (res UpdateTaskRes, err error)
	ClearSynonyms(opts ...interface{}) (res UpdateTaskRes, err error)
	DeleteSynonym(objectID string, opts ...interface{}) (res DeleteTaskRes, err error)

	// Browsing
	BrowseObjects(opts ...interface{}) (*ObjectIterator, error)
	BrowseRules(opts ...interface{}) (*RuleIterator, error)
	BrowseSynonyms(opts ...interface{}) (*SynonymIterator, error)

	// Replacing
	ReplaceAllObjects(objects interface{}, opts ...interface{}) (*wait.Group, error)
	ReplaceAllRules(rules []Rule, opts ...interface{}) (UpdateTaskRes, error)
	ReplaceAllSynonyms(synonyms []Synonym, opts ...interface{}) (UpdateTaskRes, error)

	// Searching
	Search(query string, opts ...interface{}) (res QueryRes, err error)
	SearchForFacetValues(facet, query string, opts ...interface{}) (res SearchForFacetValuesRes, err error)
	SearchRules(query string, opts ...interface{}) (res SearchRulesRes, err error)
	SearchSynonyms(query string, opts ...interface{}) (res SearchSynonymsRes, err error)

	// Settings
	GetSettings(opts ...interface{}) (settings Settings, err error)
	SetSettings(settings Settings, opts ...interface{}) (res UpdateTaskRes, err error)
}

type IndexOperation

type IndexOperation struct {
	Destination string   `json:"destination"`
	Operation   string   `json:"operation"`
	Scopes      []string `json:"scope,omitempty"`
}

type IndexRes

type IndexRes struct {
	CreatedAt            time.Time     `json:"-"`
	DataSize             int64         `json:"dataSize"`
	Entries              int64         `json:"entries"`
	FileSize             int64         `json:"fileSize"`
	LastBuildTime        time.Duration `json:"-"`
	Name                 string        `json:"name"`
	NumberOfPendingTasks int64         `json:"numberOfPendingTasks"`
	PendingTask          bool          `json:"pendingTask"`
	UpdatedAt            time.Time     `json:"-"`
}

func (*IndexRes) UnmarshalJSON

func (r *IndexRes) UnmarshalJSON(data []byte) error

type IndexedGetObject

type IndexedGetObject struct {
	IndexName            string `json:"indexName"`
	ObjectID             string `json:"objectID"`
	AttributesToRetrieve string `json:"attributesToRetrieve,omitempty"`
}

type IndexedQuery

type IndexedQuery struct {
	IndexName string `json:"indexName"`
	// contains filtered or unexported fields
}

func NewIndexedQuery

func NewIndexedQuery(index string, opts ...interface{}) IndexedQuery

func (IndexedQuery) MarshalJSON

func (p IndexedQuery) MarshalJSON() ([]byte, error)

type IndexedQueryRes

type IndexedQueryRes struct {
	Processed bool `json:"processed"`
	QueryRes
}

type Key

type Key struct {
	ACL                    []string       `json:"acl,omitempty"`
	CreatedAt              time.Time      `json:"-"`
	Description            string         `json:"description,omitempty"`
	Indexes                []string       `json:"indexes,omitempty"`
	MaxQueriesPerIPPerHour int            `json:"maxQueriesPerIPPerHour,omitempty"`
	MaxHitsPerQuery        int            `json:"maxHitsPerQuery,omitempty"`
	Referers               []string       `json:"referers,omitempty"`
	QueryParameters        KeyQueryParams `json:"-"`
	Validity               time.Duration  `json:"-"`
	Value                  string         `json:"-"`
}

Key represents an Algolia API key used by the API to identify and/or restrict calls.

func (Key) Equal

func (k Key) Equal(k2 Key) bool

Equal returns true if the Keys are equal. It returns false otherwise.

func (Key) MarshalJSON

func (k Key) MarshalJSON() ([]byte, error)

func (*Key) SetQueryParameters

func (k *Key) SetQueryParameters(opts ...interface{}) *Key

SetQueryParameters properly encodes any given query parameters into the QueryParameters field of the Key.

func (*Key) UnmarshalJSON

func (k *Key) UnmarshalJSON(data []byte) error

type KeyQueryParams

type KeyQueryParams struct {
	RestrictSources *opt.RestrictSourcesOption `json:"restrictSources,omitempty"`
	QueryParams
}

type ListAPIKeysRes

type ListAPIKeysRes struct {
	Keys []Key `json:"keys"`
}

type ListClustersRes

type ListClustersRes struct {
	Clusters []Cluster `json:"clusters"`
}

type ListIndicesRes

type ListIndicesRes struct {
	Items   []IndexRes `json:"items"`
	NbPages int        `json:"nbPages"`
}

type ListUserIDsRes

type ListUserIDsRes struct {
	UserIDs     []UserID `json:"userIDs"`
	Page        int      `json:"page"`
	HitsPerPage int      `json:"hitsPerPage"`
}

type LogRes

type LogRes struct {
	Answer         string
	AnswerCode     int
	IP             string
	Method         string
	NbAPICalls     int
	ProcessingTime time.Duration
	QueryBody      string
	QueryHeaders   string
	QueryNbHits    int
	SHA1           string
	Timestamp      time.Time
	URL            string
}

func (*LogRes) UnmarshalJSON

func (res *LogRes) UnmarshalJSON(data []byte) error

type MultipleBatchRes

type MultipleBatchRes struct {
	ObjectIDs []string       `json:"objectIDs"`
	TaskIDs   map[string]int `json:"taskID"`
	// contains filtered or unexported fields
}

func (MultipleBatchRes) Wait

func (r MultipleBatchRes) Wait() error

type MultipleQueriesRes

type MultipleQueriesRes struct {
	Results []IndexedQueryRes `json:"results"`
}

type ObjectIterator

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

ObjectIterator represents an iterator over records of an index.

ObjectIterator implements the iterator.Iterator interface.

func (*ObjectIterator) Next

func (it *ObjectIterator) Next(opts ...interface{}) (interface{}, error)

Next returns one record from the index. To directly decode the underlying object instead of getting it from the returned empty interface, passes the object to decode to as a first argument of the method, such as:

var obj struct { ... }
_, err := it.Next(&obj)

type ObjectWithPosition

type ObjectWithPosition struct {
	Object   map[string]interface{}
	Position int
	Page     int
}

type OneWaySynonym

type OneWaySynonym struct {
	Input    string
	Synonyms []string
	// contains filtered or unexported fields
}

func NewOneWaySynonym

func NewOneWaySynonym(objectID, input string, synonyms ...string) OneWaySynonym

func (OneWaySynonym) MarshalJSON

func (s OneWaySynonym) MarshalJSON() ([]byte, error)

func (OneWaySynonym) ObjectID

func (s OneWaySynonym) ObjectID() string

func (OneWaySynonym) Type

func (s OneWaySynonym) Type() SynonymType

func (*OneWaySynonym) UnmarshalJSON

func (s *OneWaySynonym) UnmarshalJSON(data []byte) error

type Placeholder

type Placeholder struct {
	Placeholder  string
	Replacements []string
	// contains filtered or unexported fields
}

func NewPlaceholder

func NewPlaceholder(objectID, placeholder string, replacements ...string) Placeholder

func (Placeholder) MarshalJSON

func (s Placeholder) MarshalJSON() ([]byte, error)

func (Placeholder) ObjectID

func (s Placeholder) ObjectID() string

func (Placeholder) Type

func (s Placeholder) Type() SynonymType

func (*Placeholder) UnmarshalJSON

func (s *Placeholder) UnmarshalJSON(data []byte) error

type PromotedObject

type PromotedObject struct {
	ObjectID string `json:"objectID"`
	Position int    `json:"position"`
}

type QueryEdit

type QueryEdit struct {
	Type   QueryEditType `json:"type"`
	Delete string        `json:"delete"`
	Insert string        `json:"insert,omitempty"`
}

func RemoveEdit

func RemoveEdit(word string) QueryEdit

func ReplaceEdit

func ReplaceEdit(old, new string) QueryEdit

type QueryEditType

type QueryEditType string
const (
	Remove  QueryEditType = "remove"
	Replace QueryEditType = "replace"
)

type QueryParams

type QueryParams struct {
	AttributesToRetrieve                    *opt.AttributesToRetrieveOption                    `json:"attributesToRetrieve,omitempty"`
	RestrictSearchableAttributes            *opt.RestrictSearchableAttributesOption            `json:"restrictSearchableAttributes,omitempty"`
	Filters                                 *opt.FiltersOption                                 `json:"filters,omitempty"`
	FacetFilters                            *opt.FacetFiltersOption                            `json:"facetFilters,omitempty"`
	OptionalFilters                         *opt.OptionalFiltersOption                         `json:"optionalFilters,omitempty"`
	NumericFilters                          *opt.NumericFiltersOption                          `json:"numericFilters,omitempty"`
	TagFilters                              *opt.TagFiltersOption                              `json:"tagFilters,omitempty"`
	SumOrFiltersScores                      *opt.SumOrFiltersScoresOption                      `json:"sumOrFiltersScores,omitempty"`
	Facets                                  *opt.FacetsOption                                  `json:"facets,omitempty"`
	MaxValuesPerFacet                       *opt.MaxValuesPerFacetOption                       `json:"maxValuesPerFacet,omitempty"`
	FacetingAfterDistinct                   *opt.FacetingAfterDistinctOption                   `json:"facetingAfterDistinct,omitempty"`
	SortFacetValuesBy                       *opt.SortFacetValuesByOption                       `json:"sortFacetValuesBy,omitempty"`
	AttributesToHighlight                   *opt.AttributesToHighlightOption                   `json:"attributesToHighlight,omitempty"`
	AttributesToSnippet                     *opt.AttributesToSnippetOption                     `json:"attributesToSnippet,omitempty"`
	HighlightPreTag                         *opt.HighlightPreTagOption                         `json:"highlightPreTag,omitempty"`
	HighlightPostTag                        *opt.HighlightPostTagOption                        `json:"highlightPostTag,omitempty"`
	SnippetEllipsisText                     *opt.SnippetEllipsisTextOption                     `json:"snippetEllipsisText,omitempty"`
	RestrictHighlightAndSnippetArrays       *opt.RestrictHighlightAndSnippetArraysOption       `json:"restrictHighlightAndSnippetArrays,omitempty"`
	Page                                    *opt.PageOption                                    `json:"page,omitempty"`
	HitsPerPage                             *opt.HitsPerPageOption                             `json:"hitsPerPage,omitempty"`
	Offset                                  *opt.OffsetOption                                  `json:"offset,omitempty"`
	Length                                  *opt.LengthOption                                  `json:"length,omitempty"`
	MinWordSizefor1Typo                     *opt.MinWordSizefor1TypoOption                     `json:"minWordSizefor1Typo,omitempty"`
	MinWordSizefor2Typos                    *opt.MinWordSizefor2TyposOption                    `json:"minWordSizefor2Typos,omitempty"`
	TypoTolerance                           *opt.TypoToleranceOption                           `json:"typoTolerance,omitempty"`
	AllowTyposOnNumericTokens               *opt.AllowTyposOnNumericTokensOption               `json:"allowTyposOnNumericTokens,omitempty"`
	DisableTypoToleranceOnAttributes        *opt.DisableTypoToleranceOnAttributesOption        `json:"disableTypoToleranceOnAttributes,omitempty"`
	AroundLatLng                            *opt.AroundLatLngOption                            `json:"aroundLatLng,omitempty"`
	AroundLatLngViaIP                       *opt.AroundLatLngViaIPOption                       `json:"aroundLatLngViaIP,omitempty"`
	AroundRadius                            *opt.AroundRadiusOption                            `json:"aroundRadius,omitempty"`
	AroundPrecision                         *opt.AroundPrecisionOption                         `json:"aroundPrecision,omitempty"`
	MinimumAroundRadius                     *opt.MinimumAroundRadiusOption                     `json:"minimumAroundRadius,omitempty"`
	InsideBoundingBox                       *opt.InsideBoundingBoxOption                       `json:"insideBoundingBox,omitempty"`
	InsidePolygon                           *opt.InsidePolygonOption                           `json:"insidePolygon,omitempty"`
	IgnorePlurals                           *opt.IgnorePluralsOption                           `json:"ignorePlurals,omitempty"`
	RemoveStopWords                         *opt.RemoveStopWordsOption                         `json:"removeStopWords,omitempty"`
	QueryLanguages                          *opt.QueryLanguagesOption                          `json:"queryLanguages,omitempty"`
	QueryType                               *opt.QueryTypeOption                               `json:"queryType,omitempty"`
	RemoveWordsIfNoResults                  *opt.RemoveWordsIfNoResultsOption                  `json:"removeWordsIfNoResults,omitempty"`
	AdvancedSyntax                          *opt.AdvancedSyntaxOption                          `json:"advancedSyntax,omitempty"`
	OptionalWords                           *opt.OptionalWordsOption                           `json:"optionalWords,omitempty"`
	DisableExactOnAttributes                *opt.DisableExactOnAttributesOption                `json:"disableExactOnAttributes,omitempty"`
	ExactOnSingleWordQuery                  *opt.ExactOnSingleWordQueryOption                  `json:"exactOnSingleWordQuery,omitempty"`
	AlternativesAsExact                     *opt.AlternativesAsExactOption                     `json:"alternativesAsExact,omitempty"`
	AdvancedSyntaxFeatures                  *opt.AdvancedSyntaxFeaturesOption                  `json:"advancedSyntaxFeatures,omitempty"`
	SimilarQuery                            *opt.SimilarQueryOption                            `json:"similarQuery,omitempty"`
	EnableRules                             *opt.EnableRulesOption                             `json:"enableRules,omitempty"`
	RuleContexts                            *opt.RuleContextsOption                            `json:"ruleContexts,omitempty"`
	EnablePersonalization                   *opt.EnablePersonalizationOption                   `json:"enablePersonalization,omitempty"`
	PersonalizationImpact                   *opt.PersonalizationImpactOption                   `json:"personalizationImpact,omitempty"`
	UserToken                               *opt.UserTokenOption                               `json:"userToken,omitempty"`
	Distinct                                *opt.DistinctOption                                `json:"distinct,omitempty"`
	GetRankingInfo                          *opt.GetRankingInfoOption                          `json:"getRankingInfo,omitempty"`
	ClickAnalytics                          *opt.ClickAnalyticsOption                          `json:"clickAnalytics,omitempty"`
	Analytics                               *opt.AnalyticsOption                               `json:"analytics,omitempty"`
	AnalyticsTags                           *opt.AnalyticsTagsOption                           `json:"analyticsTags,omitempty"`
	Synonyms                                *opt.SynonymsOption                                `json:"synonyms,omitempty"`
	ReplaceSynonymsInHighlight              *opt.ReplaceSynonymsInHighlightOption              `json:"replaceSynonymsInHighlight,omitempty"`
	MinProximity                            *opt.MinProximityOption                            `json:"minProximity,omitempty"`
	ResponseFields                          *opt.ResponseFieldsOption                          `json:"responseFields,omitempty"`
	MaxFacetHits                            *opt.MaxFacetHitsOption                            `json:"maxFacetHits,omitempty"`
	PercentileComputation                   *opt.PercentileComputationOption                   `json:"percentileComputation,omitempty"`
	Explain                                 *opt.ExplainOption                                 `json:"explain,omitempty"`
	AttributeCriteriaComputedByMinProximity *opt.AttributeCriteriaComputedByMinProximityOption `json:"attributeCriteriaComputedByMinProximity,omitempty"`
}

QueryParams represents all the parameters that can be passed at query time.

type QueryRes

type QueryRes struct {
	AppliedRules          []AppliedRule                     `json:"appliedRules"`
	AroundLatLng          string                            `json:"aroundLatLng"`
	AutomaticRadius       string                            `json:"automaticRadius"`
	ExhaustiveFacetsCount bool                              `json:"exhaustiveFacetsCount"`
	ExhaustiveNbHits      bool                              `json:"exhaustiveNbHits"`
	Explain               map[string]map[string]interface{} `json:"explain"`
	Facets                map[string]map[string]int         `json:"facets"`
	FacetsStats           map[string]FacetStat              `json:"facets_stats"`
	Hits                  []map[string]interface{}          `json:"Hits"`
	HitsPerPage           int                               `json:"hitsPerPage"`
	Index                 string                            `json:"index"`
	IndexUsed             string                            `json:"indexUsed"`
	Length                int                               `json:"length"`
	Message               string                            `json:"message"`
	NbHits                int                               `json:"nbHits"`
	NbPages               int                               `json:"nbPages"`
	Offset                int                               `json:"offset"`
	Page                  int                               `json:"page"`
	Params                string                            `json:"params"`
	ParsedQuery           string                            `json:"parsedQuery"`
	ProcessingTimeMS      int                               `json:"processingTimeMS"`
	Query                 string                            `json:"query"`
	QueryAfterRemoval     string                            `json:"queryAfterRemoval"`
	QueryID               string                            `json:"queryID"`
	ServerUsed            string                            `json:"serverUsed"`
	TimeoutCounts         bool                              `json:"timeoutCounts"`
	TimeoutHits           bool                              `json:"timeoutHits"`
	UserData              []interface{}                     `json:"userData"`
	ABTestVariantID       int                               `json:"abTestVariantID"`
}

func (QueryRes) GetObjectIDPosition deprecated

func (r QueryRes) GetObjectIDPosition(objectID string) int

GetObjectIDPosition does the same as GetObjectPosition.

Deprecated: use GetObjectPosition instead.

func (QueryRes) GetObjectPosition

func (r QueryRes) GetObjectPosition(objectID string) int

GetObjectPosition returns the position (0-based) within the `Hits` result list of the record matching against the given objectID. If the objectID is not found, -1 is returned.

func (QueryRes) UnmarshalHits

func (r QueryRes) UnmarshalHits(v interface{}) error

func (QueryRes) UnmarshalUserData

func (r QueryRes) UnmarshalUserData(v interface{}) error

type RankingInfo

type RankingInfo struct {
	Filters           int `json:"filters"`
	FirstMatchedWord  int `json:"firstMatchedWord"`
	GeoDistance       int `json:"geoDistance"`
	GeoPrecision      int `json:"geoPrecision"`
	NbExactWords      int `json:"nbExactWords"`
	NbTypos           int `json:"nbTypos"`
	ProximityDistance int `json:"proximityDistance"`
	UserScore         int `json:"userScore"`
	Words             int `json:"words"`
}

type RegularSynonym

type RegularSynonym struct {
	Synonyms []string
	// contains filtered or unexported fields
}

func NewRegularSynonym

func NewRegularSynonym(objectID string, synonyms ...string) RegularSynonym

func (RegularSynonym) MarshalJSON

func (s RegularSynonym) MarshalJSON() ([]byte, error)

func (RegularSynonym) ObjectID

func (s RegularSynonym) ObjectID() string

func (RegularSynonym) Type

func (s RegularSynonym) Type() SynonymType

func (*RegularSynonym) UnmarshalJSON

func (s *RegularSynonym) UnmarshalJSON(data []byte) error

type RemoveUserIDRes

type RemoveUserIDRes struct {
	DeletedAt string `json:"deletedAt"`
}

type RestoreKeyRes

type RestoreKeyRes struct {
	CreatedAt time.Time `json:"createdAt"`
	// contains filtered or unexported fields
}

func (RestoreKeyRes) Wait

func (r RestoreKeyRes) Wait() error

type Rule

type Rule struct {
	Condition   RuleCondition      `json:"condition"`
	Consequence RuleConsequence    `json:"consequence"`
	Description string             `json:"description,omitempty"`
	Enabled     *opt.EnabledOption `json:"enabled,omitempty"`
	ObjectID    string             `json:"objectID,omitempty"`
	Validity    []TimeRange        `json:"validity,omitempty"`
}

Rule represents an Algolia query rule.

func (Rule) Equal

func (r Rule) Equal(r2 Rule) bool

Equal returns true if the Rules are equal. It returns false otherwise.

type RuleCondition

type RuleCondition struct {
	Anchoring    RulePatternAnchoring `json:"anchoring"`
	Pattern      string               `json:"pattern"`
	Context      string               `json:"context,omitempty"`
	Alternatives *Alternatives        `json:"alternatives,omitempty"`
}

type RuleConsequence

type RuleConsequence struct {
	Params   *RuleParams      `json:"params,omitempty"`
	Promote  []PromotedObject `json:"promote,omitempty"`
	Hide     []HiddenObject   `json:"hide,omitempty"`
	UserData interface{}      `json:"userData,omitempty"`
}

type RuleIterator

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

func (*RuleIterator) Next

func (it *RuleIterator) Next(opts ...interface{}) (*Rule, error)

type RuleParams

type RuleParams struct {
	Query                         *RuleQuery             `json:"query,omitempty"`
	AutomaticFacetFilters         []AutomaticFacetFilter `json:"automaticFacetFilters,omitempty"`
	AutomaticOptionalFacetFilters []AutomaticFacetFilter `json:"automaticOptionalFacetFilters,omitempty"`
	QueryParams
}

type RulePatternAnchoring

type RulePatternAnchoring string
const (
	Is         RulePatternAnchoring = "is"
	StartsWith RulePatternAnchoring = "startsWith"
	EndsWith   RulePatternAnchoring = "endsWith"
	Contains   RulePatternAnchoring = "contains"
)

type RuleQuery

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

func NewRuleQueryObject

func NewRuleQueryObject(object RuleQueryObjectQuery) *RuleQuery

func NewRuleQuerySimple

func NewRuleQuerySimple(query string) *RuleQuery

func (RuleQuery) Get

func (RuleQuery) MarshalJSON

func (q RuleQuery) MarshalJSON() ([]byte, error)

func (*RuleQuery) UnmarshalJSON

func (q *RuleQuery) UnmarshalJSON(data []byte) error

type RuleQueryObjectQuery

type RuleQueryObjectQuery struct {
	Edits []QueryEdit `json:"edits"`
}

type SaveObjectRes

type SaveObjectRes struct {
	CreatedAt time.Time `json:"createdAt"`
	ObjectID  string    `json:"objectID"`
	TaskID    int       `json:"taskID"`
	// contains filtered or unexported fields
}

func (SaveObjectRes) Wait

func (r SaveObjectRes) Wait() error

type SearchForFacetValuesRes

type SearchForFacetValuesRes struct {
	FacetHits             []FacetHit
	ExhaustiveFacetsCount bool
	ProcessingTime        time.Duration
}

func (*SearchForFacetValuesRes) UnmarshalJSON

func (r *SearchForFacetValuesRes) UnmarshalJSON(data []byte) error

type SearchRulesRes

type SearchRulesRes struct {
	Hits    interface{} `json:"hits"`
	NbHits  int         `json:"nbHits"`
	Page    int         `json:"page"`
	NbPages int         `json:"nbPages"`
}

func (SearchRulesRes) Rules

func (r SearchRulesRes) Rules() (rules []Rule, err error)

func (SearchRulesRes) UnmarshalHits

func (r SearchRulesRes) UnmarshalHits(v interface{}) error

type SearchSynonymsRes

type SearchSynonymsRes struct {
	Hits   []map[string]interface{} `json:"hits"`
	NbHits int                      `json:"nbHits"`
}

func (SearchSynonymsRes) Synonyms

func (r SearchSynonymsRes) Synonyms() ([]Synonym, error)

type SearchUserIDRes

type SearchUserIDRes struct {
	Hits        []UserIDHit `json:"hits"`
	NbHits      int         `json:"nbHits"`
	Page        int         `json:"page"`
	HitsPerPage int         `json:"hitsPerPage"`
	UpdatedAt   int         `json:"updatedAt"`
}

type SetPersonalizationStrategyRes

type SetPersonalizationStrategyRes struct {
	UpdatedAt time.Time `json:"updatedAt"`
}

type Settings

type Settings struct {
	SearchableAttributes                    *opt.SearchableAttributesOption                    `json:"searchableAttributes,omitempty"`
	AttributesForFaceting                   *opt.AttributesForFacetingOption                   `json:"attributesForFaceting,omitempty"`
	UnretrievableAttributes                 *opt.UnretrievableAttributesOption                 `json:"unretrievableAttributes,omitempty"`
	AttributesToRetrieve                    *opt.AttributesToRetrieveOption                    `json:"attributesToRetrieve,omitempty"`
	Ranking                                 *opt.RankingOption                                 `json:"ranking,omitempty"`
	CustomRanking                           *opt.CustomRankingOption                           `json:"customRanking,omitempty"`
	Replicas                                *opt.ReplicasOption                                `json:"replicas,omitempty"`
	Primary                                 *opt.PrimaryOption                                 `json:"primary,omitempty"`
	MaxValuesPerFacet                       *opt.MaxValuesPerFacetOption                       `json:"maxValuesPerFacet,omitempty"`
	SortFacetValuesBy                       *opt.SortFacetValuesByOption                       `json:"sortFacetValuesBy,omitempty"`
	AttributesToHighlight                   *opt.AttributesToHighlightOption                   `json:"attributesToHighlight,omitempty"`
	AttributesToSnippet                     *opt.AttributesToSnippetOption                     `json:"attributesToSnippet,omitempty"`
	HighlightPreTag                         *opt.HighlightPreTagOption                         `json:"highlightPreTag,omitempty"`
	HighlightPostTag                        *opt.HighlightPostTagOption                        `json:"highlightPostTag,omitempty"`
	SnippetEllipsisText                     *opt.SnippetEllipsisTextOption                     `json:"snippetEllipsisText,omitempty"`
	RestrictHighlightAndSnippetArrays       *opt.RestrictHighlightAndSnippetArraysOption       `json:"restrictHighlightAndSnippetArrays,omitempty"`
	HitsPerPage                             *opt.HitsPerPageOption                             `json:"hitsPerPage,omitempty"`
	PaginationLimitedTo                     *opt.PaginationLimitedToOption                     `json:"paginationLimitedTo,omitempty"`
	MinWordSizefor1Typo                     *opt.MinWordSizefor1TypoOption                     `json:"minWordSizefor1Typo,omitempty"`
	MinWordSizefor2Typos                    *opt.MinWordSizefor2TyposOption                    `json:"minWordSizefor2Typos,omitempty"`
	TypoTolerance                           *opt.TypoToleranceOption                           `json:"typoTolerance,omitempty"`
	AllowTyposOnNumericTokens               *opt.AllowTyposOnNumericTokensOption               `json:"allowTyposOnNumericTokens,omitempty"`
	DisableTypoToleranceOnAttributes        *opt.DisableTypoToleranceOnAttributesOption        `json:"disableTypoToleranceOnAttributes,omitempty"`
	DisableTypoToleranceOnWords             *opt.DisableTypoToleranceOnWordsOption             `json:"disableTypoToleranceOnWords,omitempty"`
	SeparatorsToIndex                       *opt.SeparatorsToIndexOption                       `json:"separatorsToIndex,omitempty"`
	IgnorePlurals                           *opt.IgnorePluralsOption                           `json:"ignorePlurals,omitempty"`
	RemoveStopWords                         *opt.RemoveStopWordsOption                         `json:"removeStopWords,omitempty"`
	CamelCaseAttributes                     *opt.CamelCaseAttributesOption                     `json:"camelCaseAttributes,omitempty"`
	DecompoundedAttributes                  *opt.DecompoundedAttributesOption                  `json:"decompoundedAttributes,omitempty"`
	KeepDiacriticsOnCharacters              *opt.KeepDiacriticsOnCharactersOption              `json:"keepDiacriticsOnCharacters,omitempty"`
	QueryLanguages                          *opt.QueryLanguagesOption                          `json:"queryLanguages,omitempty"`
	IndexLanguages                          *opt.IndexLanguagesOption                          `json:"indexLanguages,omitempty"`
	QueryType                               *opt.QueryTypeOption                               `json:"queryType,omitempty"`
	RemoveWordsIfNoResults                  *opt.RemoveWordsIfNoResultsOption                  `json:"removeWordsIfNoResults,omitempty"`
	AdvancedSyntax                          *opt.AdvancedSyntaxOption                          `json:"advancedSyntax,omitempty"`
	OptionalWords                           *opt.OptionalWordsOption                           `json:"optionalWords,omitempty"`
	DisablePrefixOnAttributes               *opt.DisablePrefixOnAttributesOption               `json:"disablePrefixOnAttributes,omitempty"`
	DisableExactOnAttributes                *opt.DisableExactOnAttributesOption                `json:"disableExactOnAttributes,omitempty"`
	ExactOnSingleWordQuery                  *opt.ExactOnSingleWordQueryOption                  `json:"exactOnSingleWordQuery,omitempty"`
	AlternativesAsExact                     *opt.AlternativesAsExactOption                     `json:"alternativesAsExact,omitempty"`
	AdvancedSyntaxFeatures                  *opt.AdvancedSyntaxFeaturesOption                  `json:"advancedSyntaxFeatures,omitempty"`
	EnableRules                             *opt.EnableRulesOption                             `json:"enableRules,omitempty"`
	NumericAttributesForFiltering           *opt.NumericAttributesForFilteringOption           `json:"numericAttributesForFiltering,omitempty"`
	AllowCompressionOfIntegerArray          *opt.AllowCompressionOfIntegerArrayOption          `json:"allowCompressionOfIntegerArray,omitempty"`
	AttributeForDistinct                    *opt.AttributeForDistinctOption                    `json:"attributeForDistinct,omitempty"`
	Distinct                                *opt.DistinctOption                                `json:"distinct,omitempty"`
	ReplaceSynonymsInHighlight              *opt.ReplaceSynonymsInHighlightOption              `json:"replaceSynonymsInHighlight,omitempty"`
	MinProximity                            *opt.MinProximityOption                            `json:"minProximity,omitempty"`
	ResponseFields                          *opt.ResponseFieldsOption                          `json:"responseFields,omitempty"`
	MaxFacetHits                            *opt.MaxFacetHitsOption                            `json:"maxFacetHits,omitempty"`
	Advanced                                *opt.AdvancedOption                                `json:"advanced,omitempty"`
	AttributeCriteriaComputedByMinProximity *opt.AttributeCriteriaComputedByMinProximityOption `json:"attributeCriteriaComputedByMinProximity,omitempty"`
	UserData                                *opt.UserDataOption                                `json:"userData,omitempty"`
	CustomSettings                          map[string]interface{}                             `json:"-"`
}

Settings represents an index settings configuration.

func (Settings) Equal

func (s Settings) Equal(s2 Settings) bool

Equal returns true if given settings are the same as the instance one. Empty settings are considered equal to their default value counterpart.

func (Settings) MarshalJSON

func (s Settings) MarshalJSON() ([]byte, error)

func (Settings) String

func (s Settings) String() string

func (*Settings) UnmarshalJSON

func (s *Settings) UnmarshalJSON(data []byte) error

type Strategy

type Strategy struct {
	EventsScoring map[string]EventsScoring `json:"eventsScoring"`
	FacetsScoring map[string]FacetsScoring `json:"facetsScoring"`
}

type Synonym

type Synonym interface {
	ObjectID() string
	Type() SynonymType
}

type SynonymIterator

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

func (*SynonymIterator) Next

func (it *SynonymIterator) Next(opts ...interface{}) (Synonym, error)

type SynonymType

type SynonymType string
const (
	RegularSynonymType SynonymType = "synonym"
	OneWaySynonymType  SynonymType = "oneWaySynonym"
	AltCorrection1Type SynonymType = "altCorrection1"
	AltCorrection2Type SynonymType = "altCorrection2"
	PlaceholderType    SynonymType = "placeholder"
)

type TaskStatusRes

type TaskStatusRes struct {
	Status      string `json:"status"`
	PendingTask bool   `json:"pendingTask"`
}

type TimeRange

type TimeRange struct {
	From  time.Time
	Until time.Time
}

TimeRange is a pair of begin/end time.Time used to represent a rule validity (used by Rule.Validity field).

func (TimeRange) Equal

func (r TimeRange) Equal(r2 TimeRange) bool

Equal returns true if the TimeRanges are equal. It returns false otherwise.

func (TimeRange) MarshalJSON

func (r TimeRange) MarshalJSON() ([]byte, error)

func (*TimeRange) UnmarshalJSON

func (r *TimeRange) UnmarshalJSON(b []byte) error

type TopUserIDs

type TopUserIDs struct {
	PerCluster map[string][]UserIDCore `json:"topUsers"`
}

type UpdateKeyRes

type UpdateKeyRes struct {
	Key       string    `json:"key"`
	UpdatedAt time.Time `json:"updatedAt"`
	// contains filtered or unexported fields
}

func (UpdateKeyRes) Wait

func (r UpdateKeyRes) Wait() error

type UpdateTaskRes

type UpdateTaskRes struct {
	TaskID    int       `json:"taskID"`
	UpdatedAt time.Time `json:"updatedAt"`
	// contains filtered or unexported fields
}

func (UpdateTaskRes) Wait

func (r UpdateTaskRes) Wait() error

type UserID

type UserID struct {
	UserIDCore
	ClusterName string `json:"clusterName"`
}

type UserIDCore

type UserIDCore struct {
	ID        string `json:"userID"`
	NbRecords int    `json:"nbRecords"`
	DataSize  int    `json:"dataSize"`
}

type UserIDHit

type UserIDHit struct {
	UserID
	ObjectID        string      `json:"objectID"`
	HighlightResult interface{} `json:"_highlightResult"`
}

func (UserIDHit) UnmarshalHighlightResult

func (h UserIDHit) UnmarshalHighlightResult(v interface{}) error

Jump to

Keyboard shortcuts

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