zinc

package module
v0.0.0-...-47339e7 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2022 License: MIT Imports: 7 Imported by: 0

README

zinc-go

A GoLang Client for ZincSearch

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetBasicAuth

func SetBasicAuth(username, password string) clientOpt

SetBasicAuth configures the client to authenticate with Basic Auth.

func SetZincServer

func SetZincServer(url string) clientOpt

SetZincServer sets the Zinc server URL.

Types

type Client

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

Client is a ZincSearch client.

func NewClient

func NewClient(opts ...clientOpt) *Client

NewClient returns a fully initialized client.

func (*Client) CreateIndex

func (c *Client) CreateIndex() *IndexCreateService

CreateIndex returns a new IndexCreateService object allowing to create a new index.

func (*Client) DeleteIndex

func (c *Client) DeleteIndex(name string) (IndexDeleteResponse, error)

DeleteIndex deletes the given index.

func (*Client) DocumentService

func (c *Client) DocumentService() *DocumentService

DocumentService returns a new DocumentService object.

func (*Client) GetIndexMapping

func (c *Client) GetIndexMapping(name string) (IndexGetMappingResponse, error)

GetIndexMapping returns the mapping of the given index.

func (*Client) ListIndexes

func (c *Client) ListIndexes() ([]meta.Index, error)

ListIndexes returns a list of all indexes.

type DocumentCreateResponse

type DocumentCreateResponse struct {
	Message ResponseMessage `json:"message"`
	// ID is the document ID.
	ID string `json:"id"`
	// Error is the error string returned by the server.
	Error string `json:"error"`
}

DocumentCreateResponse is the response returned by the server when creating a document.

type DocumentService

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

DocumentService provides methods to create documents.

func NewDocumentService

func NewDocumentService(cli *Client) *DocumentService

NewDocumentService returns a fully initialized DocumentService.

func (*DocumentService) Create

Create creates a new document.

func (*DocumentService) CreateWithID

func (d *DocumentService) CreateWithID(ctx context.Context, id string) (DocumentCreateResponse, error)

CreateWithID creates a new document with a custom ID.

func (*DocumentService) SetData

func (d *DocumentService) SetData(data any) *DocumentService

SetData sets the target data of the document.

func (*DocumentService) SetIndex

func (d *DocumentService) SetIndex(index string) *DocumentService

SetIndex sets the target index of the document.

type HTTPResponse

type HTTPResponse struct {
	Message ResponseMessage `json:"message,omitempty"`
	Error   string          `json:"error,omitempty"`
	ID      string          `json:"id,omitempty"`
	Index   string          `json:"index,omitempty"`
	Data    interface{}     `json:"data,omitempty"`
}

HTTPResponse is the generic HTTP response.

type IndexCreateResponse

type IndexCreateResponse struct {
	Message ResponseMessage `json:"message"`
	// Index is the name of the new index.
	Index string `json:"index"`
	// StorageType is the storage type of the new index.
	StorageType meta.IndexStorageType `json:"storage_type"`
	// Error is the error string returned by the server.
	Error string `json:"error"`
}

IndexCreateResponse is the response returned by the server when creating an index.

type IndexCreateService

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

IndexCreateService provides methods to manage indicies.

func NewIndexCreateService

func NewIndexCreateService(cli *Client) *IndexCreateService

NewIndexCreateService returns a fully initialized IndexCreateService.

func (*IndexCreateService) AddMappingProperty

func (i *IndexCreateService) AddMappingProperty(prop meta.IndexMappingProperty) *IndexCreateService

AddMappingProperty adds the given index property to the index.

The IndexService object is returned to allow stacking method calls.

func (*IndexCreateService) Create

Create creates the index.

func (*IndexCreateService) IndexStorageType

func (i *IndexCreateService) IndexStorageType(storage meta.IndexStorageType) *IndexCreateService

IndexStorageType sets the storage type of the index.

The IndexService object is returned to allow stacking method calls.

func (*IndexCreateService) Name

Name sets the name of the index.

The IndexService object is returned to allow stacking method calls.

type IndexDeleteResponse

type IndexDeleteResponse struct {
	Message ResponseMessage `json:"message"`
	// Index is the name of the deleted index.
	Index string `json:"index"`
	// StorageType is the storage type of the deleted index.
	StorageType meta.IndexStorageType `json:"storage"`
	// Error is the error string returned by the server.
	Error string `json:"error"`
}

IndexDeleteResponse is the response returned by the server when deleting an index.

type IndexGetMappingResponse

type IndexGetMappingResponse struct {
	// Name is the index name.
	Name string `json:"name"`
	// Mappings holds the index mappings.
	Mappings meta.Mappings `json:"mappings"`
}

IndexGetMappingResponse holds the index mapping.

type ResponseMessage

type ResponseMessage string

ResponseMessage is a basic response from the server.

const (
	// ResponseOk indicates that the request was successful.
	ResponseOk ResponseMessage = "ok"
)

type UnknownIndexError

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

UnknownIndexError indicates that the given index is not known to the server.

func NewUnknownIndexError

func NewUnknownIndexError(name string) UnknownIndexError

NewUnknownIndexError returns a new UnknownIndexError.

func (UnknownIndexError) Error

func (u UnknownIndexError) Error() string

Error implements the errors interface.

Directories

Path Synopsis
example
pkg

Jump to

Keyboard shortcuts

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