algoliasearch

package
v1.23.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: MIT Imports: 5 Imported by: 0

README

Algolia Search Library for Go

This is a wrapper library for the Algolia Search API, designed to make it easier to integrate Algolia into Go applications. It provides a simple and intuitive interface for indexing and searching data in Algolia.

Installation

You can install the Algolia Search wrapper for Go using go get:

go get -u github.com/SimifiniiCTO/simfiny-core-lib/third-party/algoliasearch

Usage

To use the Algolia Search wrapper, you first need to create a client instance:

import "github.com/SimifiniiCTO/simfiny-core-lib/third-party/algoliasearch"

opts := []algoliasearch.Options{
    algoliasearch.WithAlgoliaSearchApplicationID("salfhgjdahgjlsdhg"),
    algoliasearch.WithAlgoliaSearchAPIKey("sdlhgjhzdgjsdhgsd"),
    algoliasearch.WithAlgoliaSearchIndexName("test")
}

client, err := algoliasearch.New(opts...)
if err != nil {
    ....
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMissingApplicationID is returned when the application id is missing
	ErrMissingApplicationID = errors.New("missing application id")
	// ErrMissingAPIKey is returned when the api key is missing
	ErrMissingAPIKey = errors.New("missing api key")
	// ErrMissingIndexName is returned when the index name is missing
	ErrMissingIndexName = errors.New("missing index name")
	// ErrMissingObjectID is returned when the object id is missing
	ErrMissingObjectID = errors.New("missing object id")
	// ErrMissingTelemetrySDK is returned when the telemetry sdk is missing
	ErrMissingTelemetrySDK = errors.New("missing telemetry sdk")
)

Functions

This section is empty.

Types

type Client

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

Client is the handler for algolia search

func New

func New(opts ...Option) (*Client, error)

NewClient creates a new algolia search handler

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, objectId string) error

Delete deletes a profile from algolia search

func (*Client) Send

func (c *Client) Send(ctx context.Context, data Record) (*string, error)

Send sends a profile to algolia search

func (*Client) Update

func (c *Client) Update(ctx context.Context, record Record) error

Update updates a profile to algolia search

type Config

type Config struct {
	// ApplicationID is the algolia application id
	ApplicationID string
	// APIKey is the algolia api key
	APIKey string
	// IndexName is the name of the index to use
	IndexName string
	// TelemetrySDK is the telemetry sdk
	TelemetrySDK *instrumentation.Client
}

Config is the configuration for the algolia search handler

func (*Config) Validate

func (c *Config) Validate() error

type IClient

type IClient interface {
	// Sends a piece of data to algolia search
	Send(ctx context.Context, data Record) (*string, error)
	// Deletes a piece of data from algolia search
	Delete(ctx context.Context, objectId string) error
	// Update updates a piece of data in algolia search
	Update(ctx context.Context, record Record) error
	// contains filtered or unexported methods
}

IClient is the interface for the algolia search handler

type Option

type Option func(*Config)

Option is a function that configures the algolia search handler

func WithAlgoliaSearchAPIKey

func WithAlgoliaSearchAPIKey(key string) Option

WithAlgoliaSearchAPIKey sets the api key for the algolia search handler

func WithAlgoliaSearchApplicationID

func WithAlgoliaSearchApplicationID(id string) Option

WithAlgoliaSearchApplicationID sets the application id for the algolia search handler

func WithAlgoliaSearchIndexName

func WithAlgoliaSearchIndexName(name string) Option

WithAlgoliaSearchIndexName sets the index name for the algolia search handler

func WithAlgoliaSearchTelemetrySDK

func WithAlgoliaSearchTelemetrySDK(sdk *instrumentation.Client) Option

WithAlgoliaSearchTelemetrySDK sets the telemetry sdk for the algolia search handler

type Record

type Record struct {
	ObjectID   string `json:"objectID"`
	DataObject any    `json:"data"`
}

Jump to

Keyboard shortcuts

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