elasticsearch

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// DefaultSharedIndexName use single shared index for small tenants
	DefaultSharedIndexName = "compass-idx-default"

	// DefaultShardCountPerIndex provides shard count in an index. For large scale, it should be at least 12
	DefaultShardCountPerIndex = 6

	// DedicatedTenantIndexPrefix is used to avoid index conflicts with system managed indices
	DedicatedTenantIndexPrefix = "compass-idx"

	// TenantIndexAliasPrefix is used to avoid index/alias conflicts, convention is same for
	// dedicated and shared tenants
	TenantIndexAliasPrefix = "compass-alias"
)

Variables

View Source
var (
	DefaultRoute = &Route{
		Index:     DefaultSharedIndexName,
		ReadKey:   uuid.Nil.String(),
		WriteKey:  uuid.Nil.String(),
		FilterKey: uuid.Nil.String(),
	}
)

Functions

func BuildAliasNameFromNamespace

func BuildAliasNameFromNamespace(ns *namespace.Namespace) string

func BuildIndexNameFromNamespace

func BuildIndexNameFromNamespace(ns *namespace.Namespace) string

func WithInstantRefresh

func WithInstantRefresh() func(*DiscoveryRepository)

WithInstantRefresh refresh the affected shards to make insert operations visible to search instantly

Types

type AssetModel

type AssetModel struct {
	asset.Asset
	NamespaceID string `json:"namespace_id"`
}

type Client

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

func NewClient

func NewClient(logger log.Logger, config Config, opts ...ClientOption) (*Client, error)

func (*Client) CreateIdxAlias

func (c *Client) CreateIdxAlias(ctx context.Context, ns *namespace.Namespace) error

func (*Client) CreateIndex

func (c *Client) CreateIndex(ctx context.Context, name string, shardCount int) error

func (*Client) IndexExists

func (c *Client) IndexExists(ctx context.Context, ns *namespace.Namespace) (bool, error)

IndexExists checks for the existence of an index

func (*Client) Init

func (c *Client) Init() (string, error)

type ClientOption

type ClientOption func(*Client)

func WithClient

func WithClient(cli *elasticsearch.Client) ClientOption

type Config

type Config struct {
	Brokers string `mapstructure:"brokers" default:"http://localhost:9200"`
}

type DiscoveryRepository

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

DiscoveryRepository implements discovery.Repository with elasticsearch as the backing store.

func NewDiscoveryRepository

func NewDiscoveryRepository(cli *Client, opts ...func(*DiscoveryRepository)) *DiscoveryRepository

func (*DiscoveryRepository) CreateNamespace

func (repo *DiscoveryRepository) CreateNamespace(ctx context.Context, ns *namespace.Namespace) error

func (*DiscoveryRepository) DeleteByID

func (repo *DiscoveryRepository) DeleteByID(ctx context.Context, ns *namespace.Namespace, assetID string) error

func (*DiscoveryRepository) DeleteByURN

func (repo *DiscoveryRepository) DeleteByURN(ctx context.Context, ns *namespace.Namespace, assetURN string) error

func (*DiscoveryRepository) Search

Search the asset store

func (*DiscoveryRepository) Suggest

func (repo *DiscoveryRepository) Suggest(ctx context.Context, cfg asset.SearchConfig) (results []string, err error)

func (*DiscoveryRepository) Upsert

func (repo *DiscoveryRepository) Upsert(ctx context.Context, ns *namespace.Namespace, ast *asset.Asset) error

type Route

type Route struct {
	// Index could be shared or a dedicated, if dedicated it will be identified by namespace name
	// for most cases it will be `DefaultSharedIndexName`
	Index string `json:"index"`
	// ReadKey route search query to respective shards
	// for most cases it will be namespace id
	ReadKey string `json:"read_key"`
	// WriteKey route index query to respective shards
	// for most cases it will be namespace id
	WriteKey string `json:"write_key"`
	// FilterKey finds set of documents uniquely for a tenant
	// for most cases it will be namespace id
	FilterKey string `json:"filter_key"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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