ElasticService
ElasticService is the abstract base class for all @opra/elastic service classes. It wires up the Elasticsearch client connection and interceptor support. You do not extend it directly — use ElasticCollectionService instead.
import { ElasticService } from '@opra/elastic';
Hierarchy: ServiceBase → ElasticService
Constructor
new ElasticService(options?: ElasticService.Options)
Interfaces
ElasticService.Options
Extends ServiceBase.Options.
| Option | Type | Description |
|---|---|---|
client | Client | ((_this) => Client) | Elasticsearch client instance. Can be a static value or a function computed per request. |
interceptor | (next, command, _this) => Promise<any> | Wraps every operation — useful for logging, tracing, or access control. |
onError | (error, _this) => void | Promise<void> | Called whenever a command throws. |
ElasticService.CrudOp
type CrudOp = 'create' | 'read' | 'update' | 'delete';
ElasticService.CommandInfo
Passed to every lifecycle hook and interceptor.
| Property | Type | Description |
|---|---|---|
crud | CrudOp | The CRUD category of the operation |
method | string | The method name (e.g. 'findMany', 'update') |
byId | boolean | Whether the operation targets a specific document by ID |
documentId | any | The document identifier, if applicable |
input | any | The input payload, if applicable |
options | any | The operation options |