algoliasearch

package
v2.25.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2018 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultReadTimeout      = 5 * time.Second
	DefaultWriteTimeout     = 30 * time.Second
	DefaultAnalyticsTimeout = 30 * time.Second

	Success Outcome = iota
	Failure
	Retry
)
View Source
const (
	DefaultConnectTimeout      = 2 * time.Second
	DefaultKeepAliveDuration   = 5 * time.Minute
	DefaultMaxIdleConnsPerHost = 64
)
View Source
const (
	AltCorrection1 string = "altCorrection1"
	AltCorrection2 string = "altCorrection2"
)
View Source
const ISO8601 = "2006-01-02T15:04:05Z"

Variables

View Source
var (
	NoMoreHitsErr               error = errors.New("No more hits")
	NoMoreSynonymsErr           error = errors.New("No more synonyms")
	NoMoreRulesErr              error = errors.New("No more rules")
	ExhaustionOfTryableHostsErr error = errors.New("All hosts have been contacted unsuccessfully")
)

Functions

func GenerateSecuredAPIKey

func GenerateSecuredAPIKey(apiKey string, params Map) (key string, err 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 `params` map. The `params` map can contain any query parameters to restrict what needs to be and can also have the following fields:

  • `userToken` (string identifier generally used to rate-limit users per IP)
  • `validUntil` (timestamp of the expiration date)
  • `restrictIndices` (comma-separated string list of the indices to restrict)
  • `referers` (string slice of allowed referers)
  • `restrictSources` (string of the allowed IPv4 network)

More details here: https://www.algolia.com/doc/rest-api/search/#request-from-browser-with-secure-restriction

func NewAnalytics

func NewAnalytics(client *client) *analytics

func NewRetryStrategy

func NewRetryStrategy(appID string, providedHosts []string) *retryStrategy

Types

type ABTest

type ABTest struct {
	Name     string
	Variants []Variant
	EndAt    time.Time
}

func (ABTest) MarshalJSON

func (abTest ABTest) MarshalJSON() ([]byte, error)

type ABTestResponse

type ABTestResponse struct {
	ABTestID               int               `json:"abTestID"`
	ClickSignificance      int               `json:"clickSignificance"`
	ConversionSignificance float64           `json:"conversionSignificance"`
	CreatedAt              time.Time         `json:"createdAt"`
	EndAt                  time.Time         `json:"endAt"`
	Name                   string            `json:"name"`
	Status                 string            `json:"status"`
	Variants               []VariantResponse `json:"variants"`
}

type ABTestTaskRes

type ABTestTaskRes struct {
	ABTestID int    `json:"abTestID"`
	Index    string `json:"index"`
	TaskID   int    `json:"taskID"`
}

type AddKeyRes

type AddKeyRes struct {
	CreatedAt string `json:"createdAt"`
	Key       string `json:"key"`
}

type Analytics

type Analytics interface {
	// AddABTest creates a new AB Test.
	AddABTest(abTest ABTest) (res ABTestTaskRes, err error)

	// DeleteABTest stops the AB Test referenced by the given ID.
	StopABTest(id int) (res ABTestTaskRes, err error)

	// DeleteABTest removes the AB Test referenced by the given ID.
	DeleteABTest(id int) (res ABTestTaskRes, err error)

	// GetABTest returns the informations relative to the AB Test referenced by
	// the given ID.
	GetABTest(id int) (res ABTestResponse, err error)

	// GetABTests retrieves a list of ABTests, according to the given
	// parameters. The returned list may not be exhaustive, depending on the
	// parameters that were provided.
	//
	// To retrieve the complete list of enabled AB tests, one should iterate
	// over the multiple pages of result returned by GetABTests until no more
	// AB Test is found.
	GetABTests(params Map) (res GetABTestsRes, err error)

	// WaitTask blocks until the given task has ended successfully. If anything
	// goes wrong or if the task did not succeed, a non-nil error is returned.
	WaitTask(task ABTestTaskRes) (err error)
}

type BatchOperation

type BatchOperation struct {
	Action string      `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"`
}

type BatchRulesRes

type BatchRulesRes struct {
	TaskID    int    `json:"taskID"`
	UpdatedAt string `json:"updatedAt"`
}

type BrowseRes

type BrowseRes struct {
	Cursor  string `json:"cursor"`
	Warning string `json:"warning"`
	QueryRes
}

type ClearRulesRes

type ClearRulesRes struct {
	TaskID    int    `json:"taskID"`
	UpdatedAt string `json:"updatedAt"`
}

type Client

type Client interface {
	// SetExtraHeader allows to set custom headers while reaching out to
	// Algolia servers.
	SetExtraHeader(key, value string)

	// SetTimeout specifies timeouts to use with the HTTP connection.
	//
	// Deprecated: Use SetReadTimeout, SetWriteTimeout or SetAnalyticsTimeout
	// instead.
	SetTimeout(connectTimeout, readTimeout int)

	// SetReadTimeout allows to specify the timeout that will be used for all
	// read requests to the Algolia Search API.
	//
	// Default value is controlled by algoliasearch.DefaultReadTimeout.
	SetReadTimeout(t time.Duration)

	// SetWriteTimeout allows to specify the timeout that will be used for all
	// write (i.e. indexing) requests to the Algolia Search API.
	//
	// Default value is controlled by algoliasearch.DefaultWriteTimeout.
	SetWriteTimeout(t time.Duration)

	// SetAnalyticsTimeout allows to specify the timeout that will be used for
	// all analytics requests to the Algolia Analytics API.
	//
	// Default value is controlled by algoliasearch.DefaultAnalyticsTimeout.
	SetAnalyticsTimeout(t time.Duration)

	// SetMaxIdleConnsPerHosts specifies the value for `MaxIdleConnsPerHost` of
	// the underlying http.Transport.
	SetMaxIdleConnsPerHosts(maxIdleConnsPerHost int)

	// SetHTTPClient allows a custom HTTP client to be specified.
	// NOTE: using this may prevent timeouts set on this client from
	// working if the underlying transport is not of type *http.Transport.
	SetHTTPClient(client *http.Client)

	// ListIndexes returns the list of all indexes belonging to this Algolia
	// application.
	ListIndexes() (indexes []IndexRes, err error)

	// ListIndexesWithRequestOptions is the same as ListIndexes but it also
	// accepts extra RequestOptions.
	ListIndexesWithRequestOptions(opts *RequestOptions) (indexes []IndexRes, err error)

	// InitIndex returns an Index object targeting `name`.
	InitIndex(name string) Index

	// InitAnalytics returns a new Analytics instance, bound to the Client.
	InitAnalytics() Analytics

	// ListKeys returns all the API keys available for this Algolia
	// application.
	//
	// Deprecated: Use ListAPIKeys instead.
	ListKeys() (keys []Key, err error)

	// ListKeysWithRequestOptions is the same as ListKeys but it also accepts
	// extra RequestOptions.
	//
	// Deprecated: Use ListAPIKeysWithRequestOptions instead.
	ListKeysWithRequestOptions(opts *RequestOptions) (keys []Key, err error)

	// ListAPIKeys returns all the API keys available for this Algolia
	// application.
	ListAPIKeys() (keys []Key, err error)

	// ListAPIKeysWithRequestOptions is the same as ListKeys but it also
	// accepts extra RequestOptions.
	ListAPIKeysWithRequestOptions(opts *RequestOptions) (keys []Key, err error)

	// MoveIndex renames the index named `source` as `destination`.
	MoveIndex(source, destination string) (UpdateTaskRes, error)

	// MoveIndexWithRequestOptions is the same as MoveIndex but it also accepts
	// extra RequestOptions.
	MoveIndexWithRequestOptions(source, destination string, opts *RequestOptions) (UpdateTaskRes, error)

	// CopyIndex duplicates the index named `source` as `destination`.
	CopyIndex(source, destination string) (UpdateTaskRes, error)

	// CopyIndexWithRequestOptions is the same as CopyIndex but it also accepts
	// extra RequestOptions.
	CopyIndexWithRequestOptions(source, destination string, opts *RequestOptions) (UpdateTaskRes, error)

	// ScopedCopyIndex duplicates the index named `source` as `destination`,
	// according to the given scopes.
	ScopedCopyIndex(source, destination string, scopes []string) (UpdateTaskRes, error)

	// ScopedCopyIndexWithRequestOptions is the same as ScopedCopyIndex but it
	// also accepts extra RequestOptions.
	ScopedCopyIndexWithRequestOptions(source, destination string, scopes []string, opts *RequestOptions) (UpdateTaskRes, error)

	// DeleteIndex removes the `name` Algolia index.
	DeleteIndex(name string) (res DeleteTaskRes, err error)

	// DeleteIndexWithRequestOptions is the same as DeleteIndex but it also
	// accepts extra RequestOptions.
	DeleteIndexWithRequestOptions(name string, opts *RequestOptions) (res DeleteTaskRes, err error)

	// ClearIndex removes every record from the `name` Algolia index.
	ClearIndex(name string) (res UpdateTaskRes, err error)

	// ClearIndexWithRequestOptions is the same as ClearIndex but it also
	// accepts extra RequestOptions.
	ClearIndexWithRequestOptions(name string, opts *RequestOptions) (res UpdateTaskRes, err error)

	// AddUserKey creates a new API key from the supplied `ACL` and the
	// specified optional parameters. More details here:
	// https://www.algolia.com/doc/rest#add-a-global-api-key
	//
	// Deprecated: Use AddAPiKey instead.
	AddUserKey(ACL []string, params Map) (AddKeyRes, error)

	// AddAPIKey creates a new API key from the supplied `ACL` and the
	// specified optional parameters. More details here:
	// https://www.algolia.com/doc/rest#add-a-global-api-key
	AddAPIKey(ACL []string, params Map) (res AddKeyRes, err error)

	// AddAPIKeyWithRequestOptions is the same as AddAPIKey but it also accepts
	// extra RequestOptions.
	AddAPIKeyWithRequestOptions(ACL []string, params Map, opts *RequestOptions) (res AddKeyRes, err error)

	// UpdateUserKey updates the API key identified by its value `key` with the
	// given parameters.
	//
	// Deprecated: Use UpdateAPIKey instead.
	UpdateUserKey(key string, params Map) (UpdateKeyRes, error)

	// UpdateAPIKey updates the API key identified by its value `key` with the
	// given parameters.
	UpdateAPIKey(key string, params Map) (res UpdateKeyRes, err error)

	// UpdateAPIKeyWithRequestOptions is the same as UpdateAPIKey but it also
	// accepts extra RequestOptions.
	UpdateAPIKeyWithRequestOptions(key string, params Map, opts *RequestOptions) (res UpdateKeyRes, err error)

	// GetUserKey returns the key identified by its value `key`.
	//
	// Deprecated: Use GetAPIKey instead.
	GetUserKey(key string) (Key, error)

	// GetAPIKey returns the key identified by its value `key`.
	GetAPIKey(key string) (res Key, err error)

	// GetAPIKeyWithRequestOptions is the same as GetAPIKey but it also accepts
	// extra RequestOptions.
	GetAPIKeyWithRequestOptions(key string, opts *RequestOptions) (res Key, err error)

	// DeleteUserKey deletes the API key identified by its `key`.
	//
	// Deprecated: Use DeleteAPIKey instead.
	DeleteUserKey(key string) (DeleteRes, error)

	// DeleteAPIKey deletes the API key identified by its `key`.
	DeleteAPIKey(key string) (res DeleteRes, err error)

	// DeleteAPIKeyWithRequestOptions is the same as DeleteAPIKey but it also
	// accepts extra RequestOptions.
	DeleteAPIKeyWithRequestOptions(key string, opts *RequestOptions) (res DeleteRes, err error)

	// GetLogs retrieves the logs according to the given `params` map which can
	// contain the following fields:
	//   - `length` (number of entries to retrieve)
	//   - `offset` (offset to the first entry)
	//   - `indexName` (index for which log entries should be retrieved)
	//   - `type` (type of logs to retrieve, can be "all", "query", "build" or
	//     "error")
	// More details here:
	// https://www.algolia.com/doc/rest-api/search/#get-last-logs
	GetLogs(params Map) (logs []LogRes, err error)

	// GetLogsWithRequestOptions is the same as GetLogs but it also accepts
	// extra RequestOptions.
	GetLogsWithRequestOptions(params Map, opts *RequestOptions) (logs []LogRes, err error)

	// MultipleQueries performs all the queries specified in `queries` and
	// aggregates the results. The `strategy` can either be set to `none`
	// (default) which executes all the queries until the last one, or set to
	// `stopIfEnoughMatches` to limit the number of results according to the
	// `hitsPerPage` parameter. More details here:
	// https://www.algolia.com/doc/rest#query-multiple-indexes
	MultipleQueries(queries []IndexedQuery, strategy string) (res []MultipleQueryRes, err error)

	// MultipleQueriesWithRequestOptions is the same as MultipleQueries but it
	// also accepts extra RequestOptions.
	MultipleQueriesWithRequestOptions(queries []IndexedQuery, strategy string, opts *RequestOptions) (res []MultipleQueryRes, err error)

	// Batch performs all queries in `operations`.
	Batch(operations []BatchOperationIndexed) (res MultipleBatchRes, err error)

	// BatchWithRequestOptions is the same as Batch but it also accepts extra
	// RequestOptions.
	BatchWithRequestOptions(operations []BatchOperationIndexed, opts *RequestOptions) (res MultipleBatchRes, err error)

	// WaitTask stops the current execution until the task identified by its
	// `taskID` on the index `indexName` is finished. The waiting time between each check is usually
	// implemented by starting at 1s and increases by a factor of 2 at each
	// retry (but is bounded at around 20min).
	WaitTask(indexName string, taskID int) error

	// WaitTaskWithRequestOptions is the same as WaitTask but it also accepts
	// extra RequestOptions.
	WaitTaskWithRequestOptions(indexName string, taskID int, opts *RequestOptions) error

	// GetStatus returns the status of a task given its ID `taskID` and `indexName`.
	GetStatus(indexName string, taskID int) (res TaskStatusRes, err error)

	// GetStatusWithRequestOptions is the same as GetStatus but it also accepts
	// extra RequestOptions.
	GetStatusWithRequestOptions(indexName string, taskID int, opts *RequestOptions) (res TaskStatusRes, err error)
}

Client is a representation of an Algolia application. Once initialized it allows manipulations over the indexes of the application as well as network related parameters.

func NewClient

func NewClient(appID, apiKey string) Client

NewClient instantiates a new `Client` from the provided `appID` and `apiKey`. Default hosts are used for the transport layer.

func NewClientWithHosts

func NewClientWithHosts(appID, apiKey string, hosts []string) Client

NewClientWithHosts instantiates a new `Client` from the provided `appID` and `apiKey`. The transport layers' hosts are initialized with the given `hosts`.

type CreateObjectRes

type CreateObjectRes struct {
	CreatedAt string `json:"createdAt"`
	ObjectID  string `json:"objectID"`
	TaskID    int    `json:"taskID"`
}

type DeleteRes

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

type DeleteRuleRes

type DeleteRuleRes struct {
	TaskID    int    `json:"taskID"`
	UpdatedAt string `json:"updatedAt"`
}

type DeleteTaskRes

type DeleteTaskRes struct {
	DeletedAt string `json:"deletedAt"`
	TaskID    int    `json:"taskID"`
}

type FacetHit

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

type GetABTestsRes

type GetABTestsRes struct {
	ABTests []ABTestResponse `json:"abtests"`
	Count   int              `json:"count"`
	Total   int              `json:"total"`
}

type Index

type Index interface {
	// Delete removes the Algolia index.
	Delete() (res DeleteTaskRes, err error)

	// DeleteWithRequestOptions is the same as Delete but it also accepts extra
	// RequestOptions.
	DeleteWithRequestOptions(opts *RequestOptions) (res DeleteTaskRes, err error)

	// Clear removes every record from the index.
	Clear() (res UpdateTaskRes, err error)

	// ClearWithRequestOptions is the same as Clear but it also accepts extra
	// RequestOptions.
	ClearWithRequestOptions(opts *RequestOptions) (res UpdateTaskRes, err error)

	// GetObject retrieves the object as an interface representing the
	// JSON-encoded object. The `objectID` is used to uniquely identify the
	// object in the index while `attributes` contains the list of attributes
	// to retrieve.
	GetObject(objectID string, attributes []string) (object Object, err error)

	// GetObjectWithRequestOptions is the same as GetObject but it also accepts
	// extra RequestOptions.
	GetObjectWithRequestOptions(objectID string, attributes []string, opts *RequestOptions) (object Object, err error)

	// GetObjects retrieves the objects identified according to their
	// `objectIDs`.
	GetObjects(objectIDs []string) (objects []Object, err error)

	// GetObjectsWithRequestOptions is the same as GetObjects but it also
	// accepts extra RequestOptions.
	GetObjectsWithRequestOptions(objectIDs []string, opts *RequestOptions) (objects []Object, err error)

	// GetObjectsAttrs retrieves the selected attributes of the objects
	// identified according to their `objectIDs`.
	GetObjectsAttrs(objectIDs, attributesToRetrieve []string) (objs []Object, err error)

	// GetObjectsAttrsWithRequestOptions is the same as GetObjectsAttrs but it
	// also accepts extra RequestOptions.
	GetObjectsAttrsWithRequestOptions(objectIDs, attributesToRetrieve []string, opts *RequestOptions) (objs []Object, err error)

	// DeleteObject deletes an object from the index that is uniquely
	// identified by its `objectID`.
	DeleteObject(objectID string) (res DeleteTaskRes, err error)

	// DeleteObjectWithRequestOptions is the same as DeleteObject but it also
	// accepts extra RequestOptions.
	DeleteObjectWithRequestOptions(objectID string, opts *RequestOptions) (res DeleteTaskRes, err error)

	// GetSettings retrieves the index's settings.
	GetSettings() (settings Settings, err error)

	// GetSettingsWithRequestOptions is the same as GetSettings but it also
	// accepts extra RequestOptions.
	GetSettingsWithRequestOptions(opts *RequestOptions) (settings Settings, err error)

	// SetSettings changes the index settings.
	SetSettings(settings Map) (res UpdateTaskRes, err error)

	// SetSettingsWithRequestOptions is the same as SetSettings but it also
	// accepts extra RequestOptions.
	SetSettingsWithRequestOptions(settings Map, opts *RequestOptions) (res UpdateTaskRes, err error)

	// WaitTask stops the current execution until the task identified by its
	// `taskID` is finished. The waiting time between each check is usually
	// implemented by starting at 1s and increases by a factor of 2 at each
	// retry (but is bounded at around 20min).
	WaitTask(taskID int) error

	// WaitTaskWithRequestOptions is the same as WaitTask but it also accepts
	// extra RequestOptions.
	WaitTaskWithRequestOptions(taskID int, opts *RequestOptions) error

	// ListKeys lists all the keys that can access the index.
	//
	// Deprecated: Use Client.ListAPIKeys instead.
	ListKeys() (keys []Key, err error)

	// ListKeysWithRequestOptions is the same as ListKeys but it also accepts
	// extra RequestOptions.
	//
	// Deprecated: Use Client.ListAPIKeysWithRequestOptions instead.
	ListKeysWithRequestOptions(opts *RequestOptions) (keys []Key, err error)

	// AddUserKey creates a new API key from the supplied `ACL` and the
	// specified optional `params` parameters for the current index. More
	// details here:
	// https://www.algolia.com/doc/rest#add-an-index-specific-api-key
	//
	// Deprecated: Use Client.AddAPIKey instead.
	AddUserKey(ACL []string, params Map) (AddKeyRes, error)

	// AddAPIKey creates a new API key from the supplied `ACL` and the
	// specified optional `params` parameters for the current index. More
	// details here:
	// https://www.algolia.com/doc/rest#add-an-index-specific-api-key
	//
	// Deprecated: Use Client.AddAPIKey instead.
	AddAPIKey(ACL []string, params Map) (res AddKeyRes, err error)

	// AddAPIKeyWithRequestOptions is the same as AddAPIKey but it also accepts
	// extra RequestOptions.
	//
	// Deprecated: Use Client.AddAPIKeyWithRequestOptions instead.
	AddAPIKeyWithRequestOptions(ACL []string, params Map, opts *RequestOptions) (res AddKeyRes, err error)

	// UpdateUserKey updates the key identified by its `key` with all the fields
	// present in the `params` Map. More details here:
	// https://www.algolia.com/doc/rest#update-an-index-specific-api-key
	//
	// Deprecated: Use Client.UpdateAPIKey instead.
	UpdateUserKey(key string, params Map) (UpdateKeyRes, error)

	// UpdateAPIKey updates the key identified by its `key` with all the fields
	// present in the `params` Map. More details here:
	// https://www.algolia.com/doc/rest#update-an-index-specific-api-key
	//
	// Deprecated: Use Client.UpdateAPIKey instead.
	UpdateAPIKey(key string, params Map) (res UpdateKeyRes, err error)

	// UpdateAPIKeyWithRequestOptions is the same as UpdateAPIKey but it also
	// accepts extra RequestOptions.
	//
	// Deprecated: Use Client.UpdateAPIKeyWithRequestOptions instead.
	UpdateAPIKeyWithRequestOptions(key string, params Map, opts *RequestOptions) (res UpdateKeyRes, err error)

	// GetUserKey retrieves the key identified by its `value`.
	//
	// Deprecated: Use Client.GetAPIKey instead.
	GetUserKey(value string) (Key, error)

	// GetAPIKey retrieves the key identified by its `value`.
	//
	// Deprecated: Use Client.GetAPIKey instead.
	GetAPIKey(value string) (key Key, err error)

	// GetAPIKeyWithRequestOptions is the same as GetAPIKey but it also accepts
	// extra RequestOptions.
	//
	// Deprecated: Use Client.GetAPIKeyWithRequestOptions instead.
	GetAPIKeyWithRequestOptions(value string, opts *RequestOptions) (key Key, err error)

	// DeleteUserKey deletes the key identified by its `value`.
	//
	// Deprecated: Use Client.DeleteAPIKey instead.
	DeleteUserKey(value string) (DeleteRes, error)

	// DeleteAPIKey deletes the key identified by its `value`.
	//
	// Deprecated: Use Client.DeleteAPIKey instead.
	DeleteAPIKey(value string) (res DeleteRes, err error)

	// DeleteAPIKeyWithRequestOptions is the same as DeleteAPIKey but it also
	// accepts extra RequestOptions.
	//
	// Deprecated: Use Client.DeleteAPIKeyWithRequestOptions instead.
	DeleteAPIKeyWithRequestOptions(value string, opts *RequestOptions) (res DeleteRes, err error)

	// AddObject adds a new record to the index.
	AddObject(object Object) (res CreateObjectRes, err error)

	// AddObjectWithRequestOptions is the same as AddObject but it also accepts
	// extra RequestOptions.
	AddObjectWithRequestOptions(object Object, opts *RequestOptions) (res CreateObjectRes, err error)

	// UpdateObject replaces the record in the index matching the one given in
	// parameter, according to its `objectID` attribute.
	UpdateObject(object Object) (res UpdateObjectRes, err error)

	// UpdateObjectWithRequestOptions is the same as UpdateObject but it also
	// accepts extra RequestOptions.
	UpdateObjectWithRequestOptions(object Object, opts *RequestOptions) (res UpdateObjectRes, err error)

	// PartialUpdateObject modifies the record in the index matching the one
	// given in parameter, according to its `objectID` attribute. However, the
	// record is only partially updated i.e. only the specified attributes will
	// be updated, the original record won't be replaced.
	PartialUpdateObject(object Object) (res UpdateTaskRes, err error)

	// PartialUpdateObjectWithRequestOptions is the same as PartialUpdateObject
	// but it also accepts extra RequestOptions.
	PartialUpdateObjectWithRequestOptions(object Object, opts *RequestOptions) (res UpdateTaskRes, err error)

	// PartialUpdateObjectNoCreate modifies the record in the index matching
	// the one given in parameter, according to its `objectID` attribute with a
	// partial update. However, if the object does not exist in the Algolia
	// index, the object is not created.
	PartialUpdateObjectNoCreate(object Object) (res UpdateTaskRes, err error)

	// PartialUpdateObjectNoCreateWithRequestOptions is the same as
	// PartialUpdateObjectNoCreate but it also accepts extra RequestOptions.
	PartialUpdateObjectNoCreateWithRequestOptions(object Object, opts *RequestOptions) (res UpdateTaskRes, err error)

	// AddObjects adds several objects to the index.
	AddObjects(objects []Object) (BatchRes, error)

	// AddObjectsWithRequestOptions is the same as AddObjects but it also
	// accepts extra RequestOptions.
	AddObjectsWithRequestOptions(objects []Object, opts *RequestOptions) (BatchRes, error)

	// UpdateObjects adds or replaces several objects at the same time,
	// according to their respective `objectID` attribute.
	UpdateObjects(objects []Object) (BatchRes, error)

	// UpdateObjectsWithRequestOptions is the same as UpdateObjects but it also
	// accepts extra RequestOptions.
	UpdateObjectsWithRequestOptions(objects []Object, opts *RequestOptions) (BatchRes, error)

	// PartialUpdateObjects partially updates several objects at the same time,
	// according to their respective `objectID` attribute.
	PartialUpdateObjects(objects []Object) (BatchRes, error)

	// PartialUpdateObjectsWithRequestOptions is the same as
	// PartialUpdateObjects but it also accepts extra RequestOptions.
	PartialUpdateObjectsWithRequestOptions(objects []Object, opts *RequestOptions) (BatchRes, error)

	// PartialUpdateObjectsNoCreate partially updates several objects at the
	// same time, according to their respective `objectID` attribute, but does
	// not create them if they do not exist.
	PartialUpdateObjectsNoCreate(objects []Object) (BatchRes, error)

	// PartialUpdateObjectsNoCreateWithRequestOptions is the same as
	// PartialUpdateObjectsNoCreate but it also accepts extra RequestOptions.
	PartialUpdateObjectsNoCreateWithRequestOptions(objects []Object, opts *RequestOptions) (BatchRes, error)

	// DeleteObjects removes several objects at the same time, according to
	// their respective `objectID` attribute.
	DeleteObjects(objectIDs []string) (BatchRes, error)

	// DeleteObjectsWithRequestOptions is the same as DeleteObjects but it also
	// accepts extra RequestOptions.
	DeleteObjectsWithRequestOptions(objectIDs []string, opts *RequestOptions) (BatchRes, error)

	// Batch processes all the specified `operations` in a batch manner. The
	// operations's actions could be one of the following:
	//   - `addObject`
	//   - `updateObject`
	//   - `partialUpdateObject`
	//   - `partialUpdateObjectNoCreate`
	//   - `deleteObject`
	//   - `clear`
	// More details here:
	// https://www.algolia.com/doc/rest#batch-write-operations.
	Batch(operations []BatchOperation) (res BatchRes, err error)

	// BatchWithRequestOptions is the same as Batch but it also accepts extra
	// RequestOptions.
	BatchWithRequestOptions(operations []BatchOperation, opts *RequestOptions) (res BatchRes, err error)

	// Copy copies the index into a new one called `name`.
	Copy(name string) (UpdateTaskRes, error)

	// CopyWithRequestOptions is the same as Copy but it also accepts extra
	// RequestOptions.
	CopyWithRequestOptions(name string, opts *RequestOptions) (UpdateTaskRes, error)

	// ScopedCopy copies the index into a new one called `name`, according to
	// the given scopes.
	ScopedCopy(name string, scopes []string) (UpdateTaskRes, error)

	// ScopedCopyWithRequestOptions is the same as ScopedCopy but it also
	// accepts extra RequestOptions.
	ScopedCopyWithRequestOptions(name string, scopes []string, opts *RequestOptions) (UpdateTaskRes, error)

	// Move renames the index into `name`.
	Move(name string) (UpdateTaskRes, error)

	// MoveWithRequestOptions is the same as Move but it also accepts extra
	// RequestOptions.
	MoveWithRequestOptions(name string, opts *RequestOptions) (UpdateTaskRes, error)

	// GetStatus returns the status of a task given its ID `taskID`.
	GetStatus(taskID int) (res TaskStatusRes, err error)

	// GetStatusWithRequestOptions is the same as GetStatus but it also accepts
	// extra RequestOptions.
	GetStatusWithRequestOptions(taskID int, opts *RequestOptions) (res TaskStatusRes, err error)

	// SearchSynonyms returns the synonyms matching `query` whose types match
	// `types`. To retrieve the first page, `page` should be set to 0.
	// `hitsPerPage` specifies how many synonym sets will be returned per page.
	SearchSynonyms(query string, types []string, page, hitsPerPage int) (synonyms []Synonym, err error)

	// SearchSynonymsWithRequestOptions is the same as SearchSynonyms but it
	// also accepts extra RequestOptions.
	SearchSynonymsWithRequestOptions(query string, types []string, page, hitsPerPage int, opts *RequestOptions) (synonyms []Synonym, err error)

	// GetSynonym retrieves the synonym identified by its `objectID`.
	GetSynonym(objectID string) (s Synonym, err error)

	// GetSynonymWithRequestOptions is the same as GetSynonym but it also
	// accepts extra RequestOptions.
	GetSynonymWithRequestOptions(objectID string, opts *RequestOptions) (s Synonym, err error)

	// AddSynonym adds the given `synonym`. This addition can be forwarded to
	// the index replicas by setting `forwardToReplicas` to `true`.
	//
	// Deprecated: Use SaveSynonym instead.
	AddSynonym(synonym Synonym, forwardToReplicas bool) (res UpdateTaskWithIDRes, err error)

	// AddSynonymWithRequestOptions is the same as AddSynonym but it also
	// accepts extra RequestOptions.
	//
	// Deprecated: Use SaveSynonymWithRequestOptions instead.
	AddSynonymWithRequestOptions(synonym Synonym, forwardToReplicas bool, opts *RequestOptions) (res UpdateTaskWithIDRes, err error)

	// SaveSynonym adds the given `synonym`. This addition can be forwarded to
	// the index replicas by setting `forwardToReplicas` to `true`.
	SaveSynonym(synonym Synonym, forwardToReplicas bool) (res UpdateTaskWithIDRes, err error)

	// SaveSynonymWithRequestOptions is the same as SaveSynonym but it also
	// accepts extra RequestOptions.
	SaveSynonymWithRequestOptions(synonym Synonym, forwardToReplicas bool, opts *RequestOptions) (res UpdateTaskWithIDRes, err error)

	// DeleteSynonym removes the synonym identified by its `objectID`. This
	// deletion can be forwarded to the index replicas by setting
	// `forwardToReplicas` to `true`.
	DeleteSynonym(objectID string, forwardToReplicas bool) (res DeleteTaskRes, err error)

	// DeleteSynonymWithRequestOptions is the same as DeleteSynonym but it also
	// accepts extra RequestOptions.
	DeleteSynonymWithRequestOptions(objectID string, forwardToReplicas bool, opts *RequestOptions) (res DeleteTaskRes, err error)

	// ClearSynonyms removes all synonyms from the index. The clear operation
	// can be forwarded to the index replicas by setting `forwardToReplicas` to
	// `true`.
	ClearSynonyms(forwardToReplicas bool) (res UpdateTaskRes, err error)

	// ClearSynonymsWithRequestOptions is the same as ClearSynonyms but it also
	// accepts extra RequestOptions.
	ClearSynonymsWithRequestOptions(forwardToReplicas bool, opts *RequestOptions) (res UpdateTaskRes, err error)

	// BatchSynonyms adds all `synonyms` to the index. The index can be cleared
	// before by setting `replaceExistingSynonyms` to `true`. The optional
	// clear operation and the additions can be forwarded to the index replicas
	// by setting `forwardToReplicas` to `true'.
	BatchSynonyms(synonyms []Synonym, replaceExistingSynonyms, forwardToReplicas bool) (res UpdateTaskRes, err error)

	// BatchSynonymsWithRequestOptions is the same as BatchSynonyms but it also
	// accepts extra RequestOptions.
	BatchSynonymsWithRequestOptions(synonyms []Synonym, replaceExistingSynonyms, forwardToReplicas bool, opts *RequestOptions) (res UpdateTaskRes, err error)

	// Browse returns the hits found according to the given `params`. The
	// `cursor` parameter controls the pagination of the results that `Browse`
	// is able to load. The first time `Browse` is called, `cursor` should be
	// an empty string. After that, subsequent calls must used the updated
	// `cursor` received in the response. This is a low-level function, if you
	// simply want to iterate through all the results, it is preferable to use
	// `BrowseAll` instead. More details here:
	// https://www.algolia.com/doc/rest#browse-all-index-content
	Browse(params Map, cursor string) (res BrowseRes, err error)

	// BrowseWithRequestOptions is the same as Browse but it also accepts extra
	// RequestOptions.
	BrowseWithRequestOptions(params Map, cursor string, opts *RequestOptions) (res BrowseRes, err error)

	// BrowseAll returns an iterator pointing to the first result that matches
	// the search query given the `params`. Calling `Next()` on the iterator
	// will returns all the hits one by one, without the 1000 elements limit of
	// the Search function. Once the last element as been reached, the next
	// call to `Next()` will return a `NoMoreHitsErr` error. If anything went
	// wrong during the browsing, a non-nil error is also returned.
	BrowseAll(params Map) (it IndexIterator, err error)

	// BrowseAllWithRequestOptions is the same as BrowseAll but it also accepts
	// extra RequestOptions.
	BrowseAllWithRequestOptions(params Map, opts *RequestOptions) (it IndexIterator, err error)

	// Search performs a search query according to the `query` search query and
	// the given `params`. More details here:
	// https://www.algolia.com/doc/rest#query-an-index
	Search(query string, params Map) (res QueryRes, err error)

	// SearchWithRequestOptions is the same as Search but it also accepts extra
	// RequestOptions.
	SearchWithRequestOptions(query string, params Map, opts *RequestOptions) (res QueryRes, err error)

	// DeleteBy finds all the records that match the given query parameters
	// and deletes them. However, those parameters do not support all the
	// options of a query, only its filters (numeric, facet, or tag) and geo
	// queries. They also do not accept empty filters or query. More details
	// here:
	// https://www.algolia.com/doc/rest-api/search/#delete-by-query
	DeleteBy(params Map) (res UpdateTaskRes, err error)

	// DeleteByWithRequestOptions is the same as DeleteBy but it also accepts
	// extra RequestOptions.
	DeleteByWithRequestOptions(params Map, opts *RequestOptions) (res UpdateTaskRes, err error)

	// DeleteByQuery finds all the records that match the `query`, according to
	// the given 'params` and deletes them. It hangs until all the deletion
	// operations have completed.
	//
	// Deprecated: Use DeleteBy instead.
	DeleteByQuery(query string, params Map) error

	// DeleteByQueryWithRequestOptions is the same as DeleteByQuery but it also
	// accepts extra RequestOptions.
	//
	// Deprecated: Use DeleteByWithRequestOptions instead.
	DeleteByQueryWithRequestOptions(query string, params Map, opts *RequestOptions) error

	// SearchFacet searches inside a facet's values, optionally
	// restricting the returned values to those contained in objects matching
	// other (regular) search criteria. The `facet` parameter is the name of
	// the facet to search (must be declared in `attributesForFaceting`). The
	// `query` string is the text used to matched against facet's values. The
	// `params` controls the search parameters you want to apply against the
	// matching records. Note that it can be `nil` and that pagination
	// parameters are not taken into account.
	//
	// Deprecated: Use SearchForFacetValues instead.
	SearchFacet(facet, query string, params Map) (res SearchFacetRes, err error)

	// SearchForFacetValues searches inside a facet's values, optionally
	// restricting the returned values to those contained in objects matching
	// other (regular) search criteria. The `facet` parameter is the name of
	// the facet to search (must be declared in `attributesForFaceting`). The
	// `query` string is the text used to matched against facet's values. The
	// `params` controls the search parameters you want to apply against the
	// matching records. Note that it can be `nil` and that pagination
	// parameters are not taken into account.
	SearchForFacetValues(facet, query string, params Map) (res SearchFacetRes, err error)

	// SearchForFacetValuesWithRequestOptions is the same as
	// SearchForFacetValues but it also accepts extra RequestOptions.
	SearchForFacetValuesWithRequestOptions(facet, query string, params Map, opts *RequestOptions) (res SearchFacetRes, err error)

	// SaveRule saves the given Rule for the current index. If a Rule with the
	// same objectID already exists, it will get overriden. The operation can
	// be forwarded to the index replicas by setting `forwardToReplicas` to
	// `true`.
	SaveRule(rule Rule, forwardToReplicas bool) (SaveRuleRes, error)

	// SaveRuleWithRequestOptions is the same as SaveRule but it also accepts
	// extra RequestOptions.
	SaveRuleWithRequestOptions(rule Rule, forwardToReplicas bool, opts *RequestOptions) (SaveRuleRes, error)

	// SaveRule saves the given Rules by batch for the current index. The
	// operation can be forwarded to the index replicas by setting
	// `forwardToReplicas` to `true`. A `clear` operation can be applied before
	// writing the new Rules by setting `clearExistingRules` to `true`.
	BatchRules(rules []Rule, forwardToReplicas, clearExistingRules bool) (BatchRulesRes, error)

	// BatchRulesWithRequestOptions is the same as BatchRules but it also
	// accepts extra RequestOptions.
	BatchRulesWithRequestOptions(rules []Rule, forwardToReplicas, clearExistingRules bool, opts *RequestOptions) (BatchRulesRes, error)

	// GetRule returns the Rule identified by the given `objectID`. A non-nil
	// error is returned if the Rule cannot be found.
	GetRule(objectID string) (*Rule, error)

	// GetRuleWithRequestOptions is the same as GetRule but it also accepts
	// extra RequestOptions.
	GetRuleWithRequestOptions(objectID string, opts *RequestOptions) (*Rule, error)

	// DeleteRule deletes the Rule identified by the given `objectID` for the
	// current index. The operation can be forwarded to the index replicas by
	// setting `forwardToReplicas` to `true`.
	DeleteRule(objectID string, forwardToReplicas bool) (DeleteRuleRes, error)

	// DeleteRuleWithRequestOptions is the same as DeleteRule but it also
	// accepts extra RequestOptions.
	DeleteRuleWithRequestOptions(objectID string, forwardToReplicas bool, opts *RequestOptions) (DeleteRuleRes, error)

	// ClearRules removes all existing Rules for the current index. The
	// operation can be forwarded to the index replicas by setting
	// `forwardToReplicas` to `true`.
	ClearRules(forwardToReplicas bool) (ClearRulesRes, error)

	// ClearRulesWithRequestOptions is the same as ClearRules but it also
	// accepts extra RequestOptions.
	ClearRulesWithRequestOptions(forwardToReplicas bool, opts *RequestOptions) (ClearRulesRes, error)

	// SearchRules allows to search for Rules for the current index. The
	// given `Map` can be populated with any of the following fields, which are
	// all optional:
	//
	//   - `query` (string):                     enable full text search within the Rule fields
	//   - `anchoring` (RulePatternAnchoring):   restricts the search to Rules with a specific anchoring type
	//   - `context` (string):                   restricts the search to rules with a specific context (exact match)
	//   - `page` (int):                         requested page (zero-based, defaults to zero)
	//   - `hitsPerPage` (int):                  maximum number of hits in a page (defaults to 20)
	SearchRules(params Map) (SearchRulesRes, error)

	// SearchRulesWithRequestOptions is the same as SearchRules but it also
	// accepts extra RequestOptions.
	SearchRulesWithRequestOptions(params Map, opts *RequestOptions) (SearchRulesRes, error)
}

Index is a representation used to manipulate an Algolia index.

func NewIndex

func NewIndex(name string, client *client) Index

NewIndex instantiates a new `Index`. The `name` parameter corresponds to the Algolia index name while the `client` is used to connect to the Algolia API.

type IndexIterator

type IndexIterator interface {
	// Next returns the next record each time is is called. Subsequent pages of
	// results are automatically loaded and an error is returned if a problem
	// occurs. When the last element is reached, an error is returned with the
	// following message: "No more hits".
	Next() (res Map, err error)
}

IndexIterator is used by the BrowseAll functions to iterate over all the records of an index (or a subset according to what the query and the params are).

type IndexOperation

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

type IndexRes

type IndexRes struct {
	CreatedAt            string `json:"createdAt"`
	DataSize             int    `json:"dataSize"`
	Entries              int    `json:"entries"`
	FileSize             int    `json:"fileSize"`
	LastBuildTimeS       int    `json:"lastBuildTimeS"`
	Name                 string `json:"name"`
	NumberOfPendingTasks int    `json:"numberOfPendingTasks"`
	PendingTask          bool   `json:"pendingTask"`
	UpdatedAt            string `json:"updatedAt"`
}

type IndexedQuery

type IndexedQuery struct {
	IndexName string
	Params    Map
}

type Key

type Key struct {
	ACL                    []string `json:"acl"`
	CreatedAt              int      `json:"createdAt,omitempty"`
	Description            string   `json:"description,omitempty"`
	Indexes                []string `json:"indexes,omitempty"`
	MaxHitsPerQuery        int      `json:"maxHitsPerQuery,omitempty"`
	MaxQueriesPerIPPerHour int      `json:"maxQueriesPerIPPerHour,omitempty"`
	QueryParamaters        string   `json:"queryParameters,omitempty"`
	Referers               []string `json:"referers,omitempty"`
	Validity               int      `json:"validity,omitempty"`
	Value                  string   `json:"value,omitempty"`
}

type LogRes

type LogRes struct {
	Answer           string `json:"answer"`
	AnswerCode       string `json:"answer_code"`
	IP               string `json:"ip"`
	Method           string `json:"method"`
	NbAPICalls       string `json:"nb_api_calls"`
	ProcessingTimeMs string `json:"processing_time_ms"`
	QueryBody        string `json:"query_body"`
	QueryHeaders     string `json:"query_headers"`
	QueryNbHits      string `json:":query_nb_hits"`
	SHA1             string `json:"sha1"`
	Timestamp        string `json:"timestamp"`
	URL              string `json:"url"`
}

type Map

type Map map[string]interface{}

type MultipleBatchRes

type MultipleBatchRes struct {
	ObjectIDs []string       `json:"objectIDs"`
	TaskID    map[string]int `json:"taskID"`
}

type MultipleQueryRes

type MultipleQueryRes struct {
	Index     string `json:"index"`
	Processed bool   `json:"processed"`
	QueryRes
}

type NetError

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

NetError is used internally to differente regular error from errors following the net.Error interface in order to propagate them with a custom message.

func NewNetError

func NewNetError(err net.Error, msg string) *NetError

func (*NetError) Error

func (e *NetError) Error() string

func (*NetError) Temporary

func (e *NetError) Temporary() bool

func (*NetError) Timeout

func (e *NetError) Timeout() bool

type Object

type Object Map

func (Object) ObjectID

func (o Object) ObjectID() (objectID string, err error)

func (Object) String

func (o Object) String() string

type Outcome

type Outcome int

type PartialUpdateOp

type PartialUpdateOp struct {
	Op    string      `json:"_operation"`
	Value interface{} `json:"value"`
}

func AddOp

func AddOp(value interface{}) PartialUpdateOp

func AddUniqueOp

func AddUniqueOp(value interface{}) PartialUpdateOp

func DecrementOp

func DecrementOp(value int) PartialUpdateOp

func IncrementOp

func IncrementOp(value int) PartialUpdateOp

func RemoveOp

func RemoveOp(value interface{}) PartialUpdateOp

type PromotedObject

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

type QueryIncrementalEdit

type QueryIncrementalEdit struct {
	Remove []string `json:"remove"`
}

type QueryRes

type QueryRes struct {
	AppliedRules          []Map  `json:"appliedRules"`
	AroundLatLng          string `json:"aroundLatLng"`
	AutomaticRadius       string `json:"automaticRadius"`
	ExhaustiveFacetsCount bool   `json:"exhaustiveFacetsCount"`
	ExhaustiveNbHits      bool   `json:"exhaustiveNbHits"`
	Facets                Map    `json:"facets"`
	FacetsStats           Map    `json:"facets_stats"`
	Hits                  []Map  `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              []Map  `json:"userData"`
}

type RequestOptions

type RequestOptions struct {
	ForwardedFor   string
	ExtraHeaders   map[string]string
	ExtraUrlParams map[string]string
}

type RetryStrategy

type RetryStrategy interface {
	// GetTryableHosts returns the slice of host to try to send the request to.
	GetTryableHosts(k call.Kind) []TryableHost

	// Decide returns an Outcome defining if the call have succeded, or failed
	// or to be retried.
	Decide(h TryableHost, code int, err error) Outcome

	// SetTimeouts updates the internal timeouts for read, write (i.e.
	// indexing) and analytics calls. Negative values are simply ignored,
	// leaving the original timeouts unchanged.
	SetTimeouts(read, write, analytics time.Duration)
}

type Rule

type Rule struct {
	ObjectID        string          `json:"objectID,omitempty"`
	Condition       RuleCondition   `json:"condition"`
	Consequence     RuleConsequence `json:"consequence"`
	Description     string          `json:"description,omitempty"`
	HighlightResult Map             `json:"_highlightResult,omitempty"`
}

type RuleCondition

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

RuleCondition is the part of an Algolia Rule which describes the condition for the rule. The `Context` is optional, hence, it will get ignored if an empty string is used to set it.

func NewRuleCondition

func NewRuleCondition(anchoring RulePatternAnchoring, pattern, context string) RuleCondition

NewRuleCondition generates a RuleCondition where all the possible fields can be specified.

func NewSimpleRuleCondition

func NewSimpleRuleCondition(anchoring RulePatternAnchoring, pattern string) RuleCondition

NewSimpleRuleCondition generates a RuleCondition where only the `Anchoring` and `Pattern` fields are specified. The optional `Context` field is then excluded.

type RuleConsequence

type RuleConsequence struct {
	Params   Map              `json:"params,omitempty"`
	Promote  []PromotedObject `json:"promote,omitempty"`
	UserData interface{}      `json:"userData,omitempty"`
}

type RuleIterator

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

RuleIterator is the exposed structure to iterate over all the rules of an index.

func NewRuleIterator

func NewRuleIterator(index Index) *RuleIterator

NewRuleIterator returns a new RuleIterator that will iterate over all the rules of the declared index.

func (*RuleIterator) Next

func (it *RuleIterator) Next() (*Rule, error)

Next returns iterate to the next rule of the underlying index. Every call to Next should yield a different rule with a nil error until the algoliasearch.NoMoreRulesErr is returned which means that all the rules have been retrieved. If the error is of a different type, it means that the iteration could not have been done correctly.

type RulePatternAnchoring

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

type SaveRuleRes

type SaveRuleRes struct {
	TaskID    int    `json:"taskID"`
	UpdatedAt string `json:"updatedAt"`
}

type SearchFacetRes

type SearchFacetRes struct {
	FacetHits             []FacetHit `json:"facetHits"`
	ExhaustiveFacetsCount bool       `json:"exhaustiveFacetsCount"`
	ProcessingTimeMS      int        `json:"processingTimeMS"`
}

type SearchRulesRes

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

type SearchSynonymsRes

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

type Settings

type Settings struct {
	// Indexing parameters
	AllowCompressionOfIntegerArray bool                `json:"allowCompressionOfIntegerArray"`
	AttributeForDistinct           string              `json:"attributeForDistinct"`
	AttributesForFaceting          []string            `json:"attributesForFaceting"`
	AttributesToIndex              []string            `json:"attributesToIndex"`
	CamelCaseAttributes            []string            `json:"camelCaseAttributes"`
	CustomRanking                  []string            `json:"customRanking"`
	DecompoundedAttributes         map[string][]string `json:"decompoundedAttributes"`
	KeepDiacriticsOnCharacters     string              `json:"keepDiacriticsOnCharacters"`
	NumericAttributesForFiltering  []string            `json:"numericAttributesForFiltering"`
	NumericAttributesToIndex       []string            `json:"numericAttributesToIndex"`
	PaginationLimitedTo            int                 `json:"paginationLimitedTo"`
	Ranking                        []string            `json:"ranking"`
	Replicas                       []string            `json:"replicas"`
	SearchableAttributes           []string            `json:"searchableAttributes"`
	SeparatorsToIndex              string              `json:"separatorsToIndex"`
	Slaves                         []string            `json:"slaves"`
	UnretrievableAttributes        []string            `json:"unretrievableAttributes"`

	// Query expansion
	DisableTypoToleranceOnAttributes []string `json:"disableTypoToleranceOnAttributes"`
	DisableTypoToleranceOnWords      []string `json:"disableTypoToleranceOnWords"`

	// Default query parameters (can be overridden at query-time)
	AdvancedSyntax                    bool        `json:"advancedSyntax"`
	AllowTyposOnNumericTokens         bool        `json:"allowTyposOnNumericTokens"`
	AttributesToHighlight             []string    `json:"attributesToHighlight"`
	AttributesToRetrieve              []string    `json:"attributesToRetrieve"`
	AttributesToSnippet               []string    `json:"attributesToSnippet"`
	Distinct                          interface{} `json:"distinct"` // float64 (actually an int) or bool
	EnableRules                       bool        `json:"enableRules"`
	HighlightPostTag                  string      `json:"highlightPostTag"`
	HighlightPreTag                   string      `json:"highlightPreTag"`
	HitsPerPage                       int         `json:"hitsPerPage"`
	IgnorePlurals                     interface{} `json:"ignorePlurals"` // []interface{} (actually a []string) or bool
	MaxFacetHits                      int         `json:"maxFacetHits"`
	MaxValuesPerFacet                 int         `json:"maxValuesPerFacet"`
	MinProximity                      int         `json:"minProximity"`
	MinWordSizefor1Typo               int         `json:"minWordSizefor1Typo"`
	MinWordSizefor2Typos              int         `json:"minWordSizefor2Typos"`
	OptionalWords                     []string    `json:"optionalWords"`
	QueryType                         string      `json:"queryType"`
	RemoveStopWords                   interface{} `json:"removeStopWords"` // []interface{} (actually a []string) or bool
	QueryLanguages                    []string    `json:"queryLanguages"`
	RemoveWordsIfNoResults            string      `json:"removeWordsIfNoResults"`
	ReplaceSynonymsInHighlight        bool        `json:"replaceSynonymsInHighlight"`
	ResponseFields                    []string    `json:"responseFields"`
	RestrictHighlightAndSnippetArrays bool        `json:"restrictHighlightAndSnippetArrays"`
	SnippetEllipsisText               string      `json:"snippetEllipsisText"`
	SortFacetValuesBy                 string      `json:"sortFacetValuesBy"`
	TypoTolerance                     string      `json:"typoTolerance"`
}

Settings is the structure returned by `GetSettigs` to ease the use of the index settings.

func (*Settings) ToMap

func (s *Settings) ToMap() Map

ToMap produces a `Map` corresponding to the `Settings struct`. It should only be used when it's needed to pass a `Settings struct` to `SetSettings`, typically when one needs to copy settings between two indices.

type Synonym

type Synonym struct {
	// Common fields
	HighlightResult Map    `json:"_highlightResult,omitempty"`
	ObjectID        string `json:"objectID"`
	Type            string `json:"type"`

	// Alternative correction synonym's fields
	Corrections []string `json:"corrections,omitempty"`
	Word        string   `json:"word,omitempty"`

	// One way synonym's fields
	Input    string   `json:"input,omitempty"`
	Synonyms []string `json:"synonyms,omitempty"`

	// Placeholder synonym's fields
	Placeholder  string   `json:"placeholder,omitempty"`
	Replacements []string `json:"replacements,omitempty"`
}

func NewAltCorrectionSynonym

func NewAltCorrectionSynonym(objectID string, corrections []string, word string, t string) Synonym

func NewOneWaySynonym

func NewOneWaySynonym(objectID string, input string, synonyms []string) Synonym

func NewPlaceholderSynonym

func NewPlaceholderSynonym(objectID string, placeholder string, replacements []string) Synonym

func NewSynonym

func NewSynonym(objectID string, synonyms []string) Synonym

type SynonymIterator

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

SynonymIterator is the exposed structure to iterate over all the synonyms of an index.

func NewSynonymIterator

func NewSynonymIterator(index Index) *SynonymIterator

NewSynonymIterator returns a new SynonymIterator that will iterate over all the synonyms of the declared index.

func (*SynonymIterator) Next

func (it *SynonymIterator) Next() (*Synonym, error)

Next returns iterate to the next synonym of the underlying index. Every call to Next should yield a different synonym with a nil error until the algoliasearch.NoMoreSynonymsErr is returned which means that all the synonyms have been retrieved. If the error is of a different type, it means that the iteration could not have been done correctly.

type TaskStatusRes

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

type Transport

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

Transport is responsible for the connection and the retry strategy to Algolia servers.

func NewTransport

func NewTransport(appID, apiKey string) *Transport

NewTransport instantiates a new Transport with the default Algolia hosts to connect to.

func NewTransportWithHosts

func NewTransportWithHosts(appID, apiKey string, hosts []string) *Transport

NewTransport instantiates a new Transport with the specificed hosts as main servers to connect to.

type TryableHost

type TryableHost interface {
	Host() string
	Timeout() time.Duration
}

type UpdateKeyRes

type UpdateKeyRes struct {
	Key       string `json:"key"`
	UpdatedAt string `json:"updatedAt"`
}

type UpdateObjectRes

type UpdateObjectRes struct {
	ObjectID  string `json:"objectID"`
	TaskID    int    `json:"taskID"`
	UpdatedAt string `json:"updatedAt"`
}

type UpdateTaskRes

type UpdateTaskRes struct {
	TaskID    int    `json:"taskID"`
	UpdatedAt string `json:"updatedAt"`
}

type UpdateTaskWithIDRes

type UpdateTaskWithIDRes struct {
	UpdateTaskRes
	ID string `json:"id"`
}

type Variant

type Variant struct {
	Index             string `json:"index"`
	TrafficPercentage int    `json:"trafficPercentage"`
	Description       string `json:"description,omitempty"`
}

type VariantResponse

type VariantResponse struct {
	AverageClickPosition int     `json:"averageClickPosition"`
	ClickCount           int     `json:"clickCount"`
	ClickThroughRate     float64 `json:"clickThroughRate"`
	ConversionCount      int     `json:"conversionCount"`
	ConversionRate       float64 `json:"conversionRate"`
	Description          string  `json:"description"`
	Index                string  `json:"index"`
	NoResultCount        int     `json:"noResultCount"`
	SearchCount          int     `json:"searchCount"`
	TrafficPercentage    int     `json:"trafficPercentage"`
	UserCount            int     `json:"userCount"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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