UNPKG

@travetto/model-elasticsearch

Version:

Elasticsearch backing for the travetto model module, with real-time modeling support for Elasticsearch mappings.

65 lines (59 loc) 1.28 kB
import type { TimeSpan } from '@travetto/runtime'; import { Config } from '@travetto/config'; import type { EsSchemaConfig } from './internal/types.ts'; /** * Elasticsearch model config */ @Config('model.elasticsearch') export class ElasticsearchModelConfig { /** * List of hosts to support */ hosts = ['127.0.0.1']; /** * Port to listen on */ port = 9200; /** * Raw elasticsearch options */ options = {}; /** * Index prefix */ namespace = 'app'; /** * Allow storage modifification */ modifyStorage?: boolean; /** * Should we store the id as a string in the document */ storeId?: boolean; /** * Base schema config for elasticsearch */ schemaConfig: EsSchemaConfig = { caseSensitive: false }; /** * Base index create settings */ indexCreate = { ['number_of_replicas']: 0, ['number_of_shards']: 1 }; /** * Frequency of culling for cullable content */ cullRate?: number | TimeSpan; /** * Build final hosts */ postConstruct(): void { console.debug('Constructed', { config: this }); this.hosts = this.hosts .map(host => host.includes(':') ? host : `${host}:${this.port}`) .map(host => host.startsWith('http') ? host : `http://${host}`); } }