Documentation
¶
Overview ¶
Package client is a generated GoMock package.
Index ¶
- type Client
- type MockClient
- func (m *MockClient) ClearScroll(ctx context.Context, scrollID string) error
- func (m *MockClient) Count(ctx context.Context, index, body string) (int64, error)
- func (m *MockClient) CreateIndex(ctx context.Context, index string) error
- func (m *MockClient) DeleteIndex(ctx context.Context, indexName string) error
- func (m *MockClient) EXPECT() *MockClientMockRecorder
- func (m *MockClient) GetMappings(ctx context.Context, indexName string) (map[string]any, error)
- func (m *MockClient) HasIndex(ctx context.Context, indexName string) (bool, error)
- func (m *MockClient) IsHealthy(ctx context.Context) error
- func (m *MockClient) IsNotFoundError(err error) bool
- func (m *MockClient) LatestTemplate() []byte
- func (m *MockClient) MappingsFromTemplate(template []byte) (map[string]any, error)
- func (m *MockClient) PutIndexTemplate(ctx context.Context, templateName string, template []byte) error
- func (m *MockClient) PutMappings(ctx context.Context, indexName string, mappings map[string]any) error
- func (m *MockClient) RunBulkProcessor(ctx context.Context, p *bulk.BulkProcessorParameters) (bulk.GenericBulkProcessor, error)
- func (m *MockClient) Scroll(ctx context.Context, index, body, scrollID string) (*Response, error)
- func (m *MockClient) Search(ctx context.Context, index, body string) (*Response, error)
- type MockClientMockRecorder
- func (mr *MockClientMockRecorder) ClearScroll(ctx, scrollID any) *gomock.Call
- func (mr *MockClientMockRecorder) Count(ctx, index, body any) *gomock.Call
- func (mr *MockClientMockRecorder) CreateIndex(ctx, index any) *gomock.Call
- func (mr *MockClientMockRecorder) DeleteIndex(ctx, indexName any) *gomock.Call
- func (mr *MockClientMockRecorder) GetMappings(ctx, indexName any) *gomock.Call
- func (mr *MockClientMockRecorder) HasIndex(ctx, indexName any) *gomock.Call
- func (mr *MockClientMockRecorder) IsHealthy(ctx any) *gomock.Call
- func (mr *MockClientMockRecorder) IsNotFoundError(err any) *gomock.Call
- func (mr *MockClientMockRecorder) LatestTemplate() *gomock.Call
- func (mr *MockClientMockRecorder) MappingsFromTemplate(template any) *gomock.Call
- func (mr *MockClientMockRecorder) PutIndexTemplate(ctx, templateName, template any) *gomock.Call
- func (mr *MockClientMockRecorder) PutMappings(ctx, indexName, mappings any) *gomock.Call
- func (mr *MockClientMockRecorder) RunBulkProcessor(ctx, p any) *gomock.Call
- func (mr *MockClientMockRecorder) Scroll(ctx, index, body, scrollID any) *gomock.Call
- func (mr *MockClientMockRecorder) Search(ctx, index, body any) *gomock.Call
- type Response
- type SearchHit
- type SearchHits
- type TotalHits
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
// ClearScroll clears the search context and results for a scrolling search.
ClearScroll(ctx context.Context, scrollID string) error
// Count returns number of document matches by given query
Count(ctx context.Context, index, body string) (int64, error)
// CreateIndex creates index with given name
CreateIndex(ctx context.Context, index string) error
// IsNotFoundError checks if error is a "not found"
IsNotFoundError(err error) bool
// RunBulkProcessor starts bulk indexing processor
// @TODO consider to extract Bulk Processor as a separate entity
RunBulkProcessor(ctx context.Context, p *bulk.BulkProcessorParameters) (bulk.GenericBulkProcessor, error)
// Scroll retrieves the next batch of results for a scrolling search.
Scroll(ctx context.Context, index, body, scrollID string) (*Response, error)
// Search returns Elasticsearch hit bytes and additional metadata
Search(ctx context.Context, index, body string) (*Response, error)
// Admin schema management methods
// IsHealthy checks if the client can connect to the server
IsHealthy(ctx context.Context) error
// PutIndexTemplate creates or updates an index template
PutIndexTemplate(ctx context.Context, templateName string, template []byte) error
// HasIndex checks if an index exists
HasIndex(ctx context.Context, indexName string) (bool, error)
// DeleteIndex deletes an index
DeleteIndex(ctx context.Context, indexName string) error
// GetMappings retrieves the mappings for an index
GetMappings(ctx context.Context, indexName string) (map[string]any, error)
// PutMappings updates the mappings for an index
PutMappings(ctx context.Context, indexName string, mappings map[string]any) error
// MappingsFromTemplate extracts mappings from a template
MappingsFromTemplate(template []byte) (map[string]any, error)
// LatestTemplate returns the latest schema template
LatestTemplate() []byte
}
Client is a generic ES client implementation. This interface allows to use different Elasticsearch and OpenSearch versions without exposing implementation details and structs
type MockClient ¶
type MockClient struct {
// contains filtered or unexported fields
}
MockClient is a mock of Client interface.
func NewMockClient ¶
func NewMockClient(ctrl *gomock.Controller) *MockClient
NewMockClient creates a new mock instance.
func (*MockClient) ClearScroll ¶
func (m *MockClient) ClearScroll(ctx context.Context, scrollID string) error
ClearScroll mocks base method.
func (*MockClient) CreateIndex ¶
func (m *MockClient) CreateIndex(ctx context.Context, index string) error
CreateIndex mocks base method.
func (*MockClient) DeleteIndex ¶
func (m *MockClient) DeleteIndex(ctx context.Context, indexName string) error
DeleteIndex mocks base method.
func (*MockClient) EXPECT ¶
func (m *MockClient) EXPECT() *MockClientMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockClient) GetMappings ¶
GetMappings mocks base method.
func (*MockClient) IsHealthy ¶
func (m *MockClient) IsHealthy(ctx context.Context) error
IsHealthy mocks base method.
func (*MockClient) IsNotFoundError ¶
func (m *MockClient) IsNotFoundError(err error) bool
IsNotFoundError mocks base method.
func (*MockClient) LatestTemplate ¶
func (m *MockClient) LatestTemplate() []byte
LatestTemplate mocks base method.
func (*MockClient) MappingsFromTemplate ¶
func (m *MockClient) MappingsFromTemplate(template []byte) (map[string]any, error)
MappingsFromTemplate mocks base method.
func (*MockClient) PutIndexTemplate ¶
func (m *MockClient) PutIndexTemplate(ctx context.Context, templateName string, template []byte) error
PutIndexTemplate mocks base method.
func (*MockClient) PutMappings ¶
func (m *MockClient) PutMappings(ctx context.Context, indexName string, mappings map[string]any) error
PutMappings mocks base method.
func (*MockClient) RunBulkProcessor ¶
func (m *MockClient) RunBulkProcessor(ctx context.Context, p *bulk.BulkProcessorParameters) (bulk.GenericBulkProcessor, error)
RunBulkProcessor mocks base method.
type MockClientMockRecorder ¶
type MockClientMockRecorder struct {
// contains filtered or unexported fields
}
MockClientMockRecorder is the mock recorder for MockClient.
func (*MockClientMockRecorder) ClearScroll ¶
func (mr *MockClientMockRecorder) ClearScroll(ctx, scrollID any) *gomock.Call
ClearScroll indicates an expected call of ClearScroll.
func (*MockClientMockRecorder) Count ¶
func (mr *MockClientMockRecorder) Count(ctx, index, body any) *gomock.Call
Count indicates an expected call of Count.
func (*MockClientMockRecorder) CreateIndex ¶
func (mr *MockClientMockRecorder) CreateIndex(ctx, index any) *gomock.Call
CreateIndex indicates an expected call of CreateIndex.
func (*MockClientMockRecorder) DeleteIndex ¶
func (mr *MockClientMockRecorder) DeleteIndex(ctx, indexName any) *gomock.Call
DeleteIndex indicates an expected call of DeleteIndex.
func (*MockClientMockRecorder) GetMappings ¶
func (mr *MockClientMockRecorder) GetMappings(ctx, indexName any) *gomock.Call
GetMappings indicates an expected call of GetMappings.
func (*MockClientMockRecorder) HasIndex ¶
func (mr *MockClientMockRecorder) HasIndex(ctx, indexName any) *gomock.Call
HasIndex indicates an expected call of HasIndex.
func (*MockClientMockRecorder) IsHealthy ¶
func (mr *MockClientMockRecorder) IsHealthy(ctx any) *gomock.Call
IsHealthy indicates an expected call of IsHealthy.
func (*MockClientMockRecorder) IsNotFoundError ¶
func (mr *MockClientMockRecorder) IsNotFoundError(err any) *gomock.Call
IsNotFoundError indicates an expected call of IsNotFoundError.
func (*MockClientMockRecorder) LatestTemplate ¶
func (mr *MockClientMockRecorder) LatestTemplate() *gomock.Call
LatestTemplate indicates an expected call of LatestTemplate.
func (*MockClientMockRecorder) MappingsFromTemplate ¶
func (mr *MockClientMockRecorder) MappingsFromTemplate(template any) *gomock.Call
MappingsFromTemplate indicates an expected call of MappingsFromTemplate.
func (*MockClientMockRecorder) PutIndexTemplate ¶
func (mr *MockClientMockRecorder) PutIndexTemplate(ctx, templateName, template any) *gomock.Call
PutIndexTemplate indicates an expected call of PutIndexTemplate.
func (*MockClientMockRecorder) PutMappings ¶
func (mr *MockClientMockRecorder) PutMappings(ctx, indexName, mappings any) *gomock.Call
PutMappings indicates an expected call of PutMappings.
func (*MockClientMockRecorder) RunBulkProcessor ¶
func (mr *MockClientMockRecorder) RunBulkProcessor(ctx, p any) *gomock.Call
RunBulkProcessor indicates an expected call of RunBulkProcessor.
type Response ¶
type Response struct {
TookInMillis int64
TotalHits int64
Hits *SearchHits
Aggregations map[string]json.RawMessage
Sort []interface{}
ScrollID string
}
Response is used to pass data retrieved from Elasticsearch/OpenSearch to upper layer
type SearchHit ¶
type SearchHit struct {
Index string // index name
ID string // external or internal
Sort []interface{} // sort information
Source json.RawMessage // stored document source
}
SearchHit is a single hit.
type SearchHits ¶
type SearchHits struct {
TotalHits *TotalHits // total number of hits found
Hits []*SearchHit // the actual hits returned
}
SearchHits specifies the list of search hits.