Skip to main content

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: ServiceBaseElasticService


Constructor

new ElasticService(options?: ElasticService.Options)

Interfaces

ElasticService.Options

Extends ServiceBase.Options.

OptionTypeDescription
clientClient | ((_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.

PropertyTypeDescription
crudCrudOpThe CRUD category of the operation
methodstringThe method name (e.g. 'findMany', 'update')
byIdbooleanWhether the operation targets a specific document by ID
documentIdanyThe document identifier, if applicable
inputanyThe input payload, if applicable
optionsanyThe operation options