Documentation ¶
Index ¶
- func SetBasicAuth(username, password string) clientOpt
- func SetZincServer(url string) clientOpt
- type Client
- func (c *Client) CreateIndex() *IndexCreateService
- func (c *Client) DeleteIndex(name string) (IndexDeleteResponse, error)
- func (c *Client) DocumentService() *DocumentService
- func (c *Client) GetIndexMapping(name string) (IndexGetMappingResponse, error)
- func (c *Client) ListIndexes() ([]meta.Index, error)
- type DocumentCreateResponse
- type DocumentService
- func (d *DocumentService) Create(ctx context.Context) (DocumentCreateResponse, error)
- func (d *DocumentService) CreateWithID(ctx context.Context, id string) (DocumentCreateResponse, error)
- func (d *DocumentService) SetData(data any) *DocumentService
- func (d *DocumentService) SetIndex(index string) *DocumentService
- type HTTPResponse
- type IndexCreateResponse
- type IndexCreateService
- func (i *IndexCreateService) AddMappingProperty(prop meta.IndexMappingProperty) *IndexCreateService
- func (i *IndexCreateService) Create(ctx context.Context) (IndexCreateResponse, error)
- func (i *IndexCreateService) IndexStorageType(storage meta.IndexStorageType) *IndexCreateService
- func (i *IndexCreateService) Name(name string) *IndexCreateService
- type IndexDeleteResponse
- type IndexGetMappingResponse
- type ResponseMessage
- type UnknownIndexError
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.
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 ¶
func (d *DocumentService) Create(ctx context.Context) (DocumentCreateResponse, error)
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 ¶
func (i *IndexCreateService) Create(ctx context.Context) (IndexCreateResponse, error)
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 ¶
func (i *IndexCreateService) Name(name string) *IndexCreateService
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.