elasticsearch

package
v0.0.0-...-4c7c1d8 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2025 License: Apache-2.0 Imports: 22 Imported by: 1

Documentation

Index

Constants

View Source
const IndexNameUser = "user"
View Source
const PrefixMinChars = 3

Variables

View Source
var ErrMissingCredential = apierrors.InternalError.WithReason("SearchDisabled").New("elasticsearch credential is not provided")

Functions

func CursorToSearchAfter

func CursorToSearchAfter(cursor model.PageCursor) (searchAfter interface{}, err error)

func MakeSearchBody

func MakeSearchBody(
	appID config.AppID,
	searchKeyword string,
	filterOptions libuser.FilterOptions,
	sortOption libuser.SortOption,
) map[string]interface{}

func NewClient

func NewClient(credentials *config.ElasticsearchCredentials) *elasticsearch.Client

func SortToCursor

func SortToCursor(sort interface{}) (cursor model.PageCursor, err error)

Types

type ElasticsearchServiceLogger

type ElasticsearchServiceLogger struct{ *log.Logger }

func NewElasticsearchServiceLogger

func NewElasticsearchServiceLogger(lf *log.Factory) *ElasticsearchServiceLogger

type ReindexRequest

type ReindexRequest struct {
	UserID string `json:"user_id"`
}

type ReindexResult

type ReindexResult struct {
	UserID       string `json:"user_id"`
	IsSuccess    bool   `json:"is_success"`
	ErrorMessage string `json:"error_message,omitempty"`
}

type Service

type Service struct {
	Clock           clock.Clock
	Database        *appdb.Handle
	Logger          *ElasticsearchServiceLogger
	AppID           config.AppID
	Client          *elasticsearch.Client
	Users           UserQueries
	UserStore       *user.Store
	IdentityService *identityservice.Service
	RolesGroups     *rolesgroups.Store
}

func (*Service) DeleteUser

func (s *Service) DeleteUser(userID string) error

func (*Service) QueryUser

func (s *Service) QueryUser(
	searchKeyword string,
	filterOptions libuser.FilterOptions,
	sortOption libuser.SortOption,
	pageArgs graphqlutil.PageArgs,
) ([]model.PageItemRef, *Stats, error)

func (*Service) ReindexUser

func (s *Service) ReindexUser(user *model.SearchUserSource) error

type Stats

type Stats struct {
	TotalCount int
}

type UserQueries

type UserQueries interface {
	Get(ctx context.Context, userID string, role accesscontrol.Role) (*model.User, error)
}

Jump to

Keyboard shortcuts

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