searchengine

package
v0.20.1 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// IndexUser is the name of the MeiliSearch index for users.
	IndexUser = "s42_users"
	// IndexUserPrimaryKey is the primary key for the MeiliSearch index
	// for users.
	IndexUserPrimaryKey = "id"
)

Variables

This section is empty.

Functions

func Initizialize

func Initizialize()

Initizialize the search engine. It should be called at startup. (should be called after viper is initialized due to dependency on viper)

Types

type Client

type Client struct {
	*meilisearch.Client
}

func NewClient

func NewClient() *Client

NewClient creates a new MeiliSearch client and returns it. It uses the configuration to get the host and the API key.

func (*Client) DeleteUserDocument

func (c *Client) DeleteUserDocument(userID uuid.UUID) error

func (*Client) EnsureAllIndexes

func (c *Client) EnsureAllIndexes() error

EnsureAllIndexes ensures that all the MeiliSearch indexes exist and are configured correctly. It should be called at startup.

func (*Client) EnsureUserIndex

func (c *Client) EnsureUserIndex() error

func (*Client) SearchUser

func (c *Client) SearchUser(query string, onlyOnline bool) ([]uuid.UUID, error)

SearchUser searches for a user in the MeiliSearch index. It returns a slice of UUIDs of the users found.

func (*Client) UpdateUserDocument

func (c *Client) UpdateUserDocument(ctx context.Context, document *UserDocument) error

UpdateUserDocument updates the MeiliSearch document for the given user. It should be called when a user is created or updated. It will create the document if it doesn't exist. It will update it if it does.

type UserDocument

type UserDocument struct {
	ID              uuid.UUID  `json:"id"`
	CurrentCampusID *uuid.UUID `json:"current_campus_id,omitempty"`
	HasOnline       *bool      `json:"has_online,omitempty"`
	DuoLogin        string     `json:"duo_login,omitempty"`
	FirstName       string     `json:"first_name,omitempty"`
	UsualFirstName  *string    `json:"usual_first_name,omitempty"`
	LastName        string     `json:"last_name,omitempty"`
}

UserDocument is a struct that represents a user in the MeiliSearch index.

Jump to

Keyboard shortcuts

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