search

package
v1.0.0-beta.122 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const StreamContentType = "application/x-json-stream"

Variables

This section is empty.

Functions

func IsErrDuplicateEntity

func IsErrDuplicateEntity(err error) bool

func IsErrDuplicateFieldNames

func IsErrDuplicateFieldNames(err error) bool

func IsErrNotFound

func IsErrNotFound(err error) bool

func NewSearchError

func NewSearchError(httpCode int, code ErrCode, msg string, args ...any) error

Types

type ErrCode

type ErrCode byte
const (
	ErrCodeInvalid           ErrCode = 0x00
	ErrCodeDuplicate         ErrCode = 0x01
	ErrCodeNotFound          ErrCode = 0x02
	ErrCodeIndexingDocuments ErrCode = 0x03
	ErrCodeUnhandled         ErrCode = 0x04
)

type Error

type Error struct {
	HttpCode int
	Code     ErrCode
	Msg      string
}

func (Error) Error

func (se Error) Error() string

type IndexAction

type IndexAction string
var (
	Create  IndexAction = "create"
	Replace IndexAction = "upsert"
	Update  IndexAction = "update"
)

type IndexDocumentsOptions

type IndexDocumentsOptions struct {
	Action    IndexAction
	BatchSize int
}

type IndexResp

type IndexResp struct {
	Code     int
	Document string
	Error    string
	Success  bool
}

type NoopStore

type NoopStore struct{}

func (*NoopStore) AllCollections

func (*NoopStore) AllCollections(context.Context) (map[string]*tsApi.CollectionResponse, error)

func (*NoopStore) CreateCollection

func (*NoopStore) CreateCollection(context.Context, *tsApi.CollectionSchema) error

func (*NoopStore) CreateDocument

func (*NoopStore) CreateDocument(_ context.Context, _ string, _ map[string]any) error

func (*NoopStore) DeleteDocument

func (*NoopStore) DeleteDocument(context.Context, string, string) error

func (*NoopStore) DeleteDocuments

func (*NoopStore) DeleteDocuments(context.Context, string, *filter.WrappedFilter) (int, error)

func (*NoopStore) DescribeCollection

func (*NoopStore) DescribeCollection(context.Context, string) (*tsApi.CollectionResponse, error)

func (*NoopStore) DropCollection

func (*NoopStore) DropCollection(context.Context, string) error

func (*NoopStore) GetDocuments

func (*NoopStore) GetDocuments(_ context.Context, _ string, _ []string) (*tsApi.SearchResult, error)

func (*NoopStore) IndexDocuments

func (*NoopStore) Search

func (*NoopStore) UpdateCollection

type Store

type Store interface {
	// AllCollections is to describe all search indexes.
	AllCollections(ctx context.Context) (map[string]*tsApi.CollectionResponse, error)
	// DescribeCollection is to describe a search index.
	DescribeCollection(ctx context.Context, name string) (*tsApi.CollectionResponse, error)
	// CreateCollection is to create a search index.
	CreateCollection(ctx context.Context, schema *tsApi.CollectionSchema) error
	// UpdateCollection is to update the search index.
	UpdateCollection(ctx context.Context, name string, schema *tsApi.CollectionUpdateSchema) error
	// DropCollection is to drop the search index.
	DropCollection(ctx context.Context, table string) error
	// CreateDocument is to create and index a single document
	CreateDocument(_ context.Context, table string, doc map[string]any) error
	// IndexDocuments is to index batch of documents. It expects index action to decide whether it needs to create/upsert/update documents.
	IndexDocuments(ctx context.Context, table string, documents io.Reader, options IndexDocumentsOptions) ([]IndexResp, error) // bytes written - bytes from io.Reader
	// DeleteDocument is deleting a single document using id.
	DeleteDocument(ctx context.Context, table string, key string) error
	// DeleteDocuments is to delete multiple documents using filter.
	DeleteDocuments(ctx context.Context, table string, filter *filter.WrappedFilter) (int, error)
	// Search is to search using Query.
	Search(ctx context.Context, table string, query *qsearch.Query, pageNo int) ([]tsApi.SearchResult, error)
	// GetDocuments is to get a single or multiple documents by id.
	GetDocuments(ctx context.Context, table string, ids []string) (*tsApi.SearchResult, error)
}

func NewStore

func NewStore(config *config.SearchConfig, withMetrics bool) Store

Jump to

Keyboard shortcuts

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