Configuration
@nx/searchreads env from the host process (commerce). It defines its own keys (src/common/environments.ts) on top of@nx/coreKafka keys, plus DB-backed embedding + pipeline config in theConfigurationtable.
1. Environment Variables
Search-specific (EnvironmentKeys extends core)
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
APP_ENV_TYPESENSE_NODES | string (CSV) | http:localhost:8108 | Nodes as protocol:host:port, comma-separated. Not a URL | |
APP_ENV_TYPESENSE_API_KEY | string | xyz | Typesense API key | |
APP_ENV_CDC_DLQ_TOPIC | string | nx.seller.cdc.dlq | Dead-letter topic for failed CDC messages | |
APP_ENV_CDC_CIRCUIT_BREAKER_ENABLED | boolean (string) | false | Enable Typesense health probe + consumer pause |
Kafka / CDC consumer (inherited from @nx/core)
| Name | Type | Default | Description |
|---|---|---|---|
APP_ENV_KAFKA_BROKERS | string (CSV) | localhost:19092 | Bootstrap brokers |
APP_ENV_KAFKA_CLIENT_ID | string | commerce-cdc-consumer | CDC consumer client id |
APP_ENV_KAFKA_GROUP_ID | string | commerce-cdc-group | CDC consumer group |
APP_ENV_KAFKA_SASL_ENABLE | boolean (string) | false | Enable SASL |
APP_ENV_KAFKA_SASL_MECHANISM | string | SCRAM-SHA-512 | SASL mechanism (when enabled) |
APP_ENV_KAFKA_SASL_USERNAME | string | — | SASL user (when enabled) |
APP_ENV_KAFKA_SASL_PASSWORD | string | — | SASL password (when enabled) |
The
commerce-cdc-*defaults reflect the current host; they are not hard-coded to a "search" service.
2. Feature Flags
| Flag | Default | Description |
|---|---|---|
APP_ENV_CDC_CIRCUIT_BREAKER_ENABLED | false | Gate the CDC circuit breaker (health probe + pause) |
ISearchParams.disableSemanticSearch | false (per-query) | Drop the embedding field from query_by → strict keyword |
Auto-embedding (embed.from) | off unless DB config present | Enabled only when embedding model config exists + collection has embeddingField/embeddingFields |
3. Seeded Data
No PostgreSQL migrations of its own. "Seeding" is via developer scripts that feed/backfill data:
| Script | Command | Action | Idempotent |
|---|---|---|---|
scripts/data-feeder/index.ts | bun run feed-data[:small|medium|large] | Generate fake data, POST via Commerce API (needs JWT) | no (creates rows) |
scripts/migrate-add-references.ts | bun run migrate:references[:dry] | Backfill relation/reference fields in Typesense | yes |
scripts/migrate-add-denorm-fields.ts | bun run migrate:denorm[:dry] | Backfill denormalized fields in Typesense | yes |
4. Configuration Storage (Configuration table)
Read by SearchConfigurationService at bootstrap; falls back to DEFAULT_SEARCH_PIPELINE_CONFIG.
| Configuration kind | Read by | Binds | Notes |
|---|---|---|---|
TYPESENSE_EMBEDDING_CONFIG (SystemConfigurations) | ApplicationEmbeddingConfigurationComponent | EMBEDDING_MODEL_CONFIG | Optional; absent → keyword-only search |
| Search pipeline config | ApplicationEmbeddingConfigurationComponent | SEARCH_PIPELINE_CONFIG | Partial override merged onto defaults |
Pipeline config defaults (DEFAULT_SEARCH_PIPELINE_CONFIG)
| Group | Field | Default |
|---|---|---|
cdc.kafkaConsumer | maxWaitTimeMs / maxBytes | 500 / 5 MB |
cdc.batching | maxBatchSize / flushIntervalMs | 200 / 2000 |
cdc.processing | typesenseBatchSize | 100 |
circuitBreaker | probeIntervalMs | 30 000 |
circuitBreaker | quietWindowMsTypesense / quietWindowMsGoogle | 30 000 / 90 000 |
circuitBreaker | maxOpenMs | 1 800 000 (30 min) |
lsnLookup | pageSize | 250 |
search | cacheTtlSeconds | 5 |
search | paginationDefaultLimit / paginationMaxLimit | 10 / 250 |