MCPcopy
hub / github.com/gofr-dev/gofr / Elasticsearch

Interface Elasticsearch

pkg/gofr/container/datasources.go:752–782  ·  view source on GitHub ↗

Elasticsearch defines all the operations GoFr users need.

Source from the content-addressed store, hash-verified

750
751// Elasticsearch defines all the operations GoFr users need.
752type Elasticsearch interface {
753 // CreateIndex creates a new index with optional mapping/settings.
754 CreateIndex(ctx context.Context, index string, settings map[string]any) error
755
756 // DeleteIndex deletes an existing index.
757 DeleteIndex(ctx context.Context, index string) error
758
759 // IndexDocument indexes (creates or replaces) a single document.
760 IndexDocument(ctx context.Context, index, id string, document any) error
761
762 // GetDocument retrieves a single document by ID.
763 // Returns the raw JSON as a map.
764 GetDocument(ctx context.Context, index, id string) (map[string]any, error)
765
766 // UpdateDocument applies a partial update to an existing document.
767 UpdateDocument(ctx context.Context, index, id string, update map[string]any) error
768
769 // DeleteDocument removes a document by ID.
770 DeleteDocument(ctx context.Context, index, id string) error
771
772 // Bulk executes multiple indexing/updating/deleting operations in one request.
773 // Each entry in `operations` should be a JSON‑serializable object
774 // following the Elasticsearch bulk API format.
775 Bulk(ctx context.Context, operations []map[string]any) (map[string]any, error)
776
777 // Search executes a query against one or more indices.
778 // Returns the entire response JSON as a map.
779 Search(ctx context.Context, indices []string, query map[string]any) (map[string]any, error)
780
781 HealthChecker
782}
783
784// ElasticsearchProvider an interface that extends Elasticsearch with additional methods for logging, metrics, and connection management.
785//

Callers

nothing calls this directly

Implementers 8

MockElasticsearchpkg/gofr/container/mock_datasources.go
MockElasticsearchMockRecorderpkg/gofr/container/mock_datasources.go
MockElasticsearchProviderpkg/gofr/container/mock_datasources.go
MockElasticsearchProviderMockRecorderpkg/gofr/container/mock_datasources.go
Clientpkg/gofr/datasource/elasticsearch/elas
MockElasticsearchpkg/gofr/migration/mock_interface.go
MockElasticsearchMockRecorderpkg/gofr/migration/mock_interface.go
trackedElasticsearchpkg/gofr/migration/tracker.go

Calls

no outgoing calls

Tested by

no test coverage detected