Documentation ¶
Index ¶
- Constants
- func Initizialize()
- type Client
- func (c *Client) DeleteUserDocument(userID uuid.UUID) error
- func (c *Client) EnsureAllIndexes() error
- func (c *Client) EnsureUserIndex() error
- func (c *Client) SearchUser(query string, onlyOnline bool) ([]uuid.UUID, error)
- func (c *Client) UpdateUserDocument(ctx context.Context, document *UserDocument) error
- type UserDocument
Constants ¶
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) EnsureAllIndexes ¶
EnsureAllIndexes ensures that all the MeiliSearch indexes exist and are configured correctly. It should be called at startup.
func (*Client) SearchUser ¶
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.