Skip to content

Commit bd2cf3e

Browse files
dnplkndllclaude
andcommitted
feat: configurable fulltext backend via FULLTEXT_BACKEND env var
Wire up the new OpenSearch and Typesense adapters in the fulltext pod. The FULLTEXT_BACKEND env var selects the adapter at startup: - "elastic" (default): existing Elasticsearch 7.x - "opensearch": OpenSearch 2.x (API-compatible drop-in) - "typesense": Typesense (lightweight C++ engine) Register both new packages in rush.json and add them as fulltext pod dependencies. ELASTIC_INDEX_NAME now defaults to 'huly_storage_index' instead of requiring it for all backends. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Don Kendall <kendall@donkendall.com>
1 parent a4905df commit bd2cf3e

3 files changed

Lines changed: 34 additions & 7 deletions

File tree

pods/fulltext/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969
"@koa/cors": "^5.0.0",
7070
"@hcengineering/server-indexer": "workspace:^0.7.0",
7171
"@hcengineering/elastic": "workspace:^0.7.16",
72+
"@hcengineering/opensearch": "workspace:^0.7.17",
73+
"@hcengineering/typesense": "workspace:^0.7.17",
7274
"@hcengineering/server-collaboration": "workspace:^0.7.0",
7375
"@hcengineering/middleware": "workspace:^0.7.21",
7476
"@hcengineering/server-client": "workspace:^0.7.16",

pods/fulltext/src/index.ts

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,16 @@
1616
import { Analytics } from '@hcengineering/analytics'
1717
import { configureAnalytics, createOpenTelemetryMetricsContext, SplitLogger } from '@hcengineering/analytics-service'
1818
import { newMetrics, type Tx } from '@hcengineering/core'
19-
import { initStatisticsContext, type StorageConfiguration } from '@hcengineering/server-core'
19+
import {
20+
initStatisticsContext,
21+
type StorageConfiguration,
22+
type FullTextAdapterFactory
23+
} from '@hcengineering/server-core'
2024
import { join } from 'path'
2125

2226
import { createElasticAdapter } from '@hcengineering/elastic'
27+
import { createOpenSearchAdapter } from '@hcengineering/opensearch'
28+
import { createTypesenseAdapter } from '@hcengineering/typesense'
2329
import { getPlatformQueue } from '@hcengineering/kafka'
2430
import { setMetadata } from '@hcengineering/platform'
2531
import { createRekoniAdapter, type FulltextDBConfiguration } from '@hcengineering/server-indexer'
@@ -74,9 +80,22 @@ if (rekoniUrl === undefined) {
7480
process.exit(1)
7581
}
7682

83+
const fulltextBackend = (process.env.FULLTEXT_BACKEND ?? 'elastic').toLowerCase()
84+
const fulltextAdapterFactories: Record<string, FullTextAdapterFactory> = {
85+
elastic: createElasticAdapter,
86+
opensearch: createOpenSearchAdapter,
87+
typesense: createTypesenseAdapter
88+
}
89+
const fulltextFactory = fulltextAdapterFactories[fulltextBackend]
90+
if (fulltextFactory === undefined) {
91+
console.error(`Unknown FULLTEXT_BACKEND: "${fulltextBackend}". Supported: elastic, opensearch, typesense`)
92+
process.exit(1)
93+
}
94+
console.info(`Using fulltext backend: ${fulltextBackend}`)
95+
7796
const config: FulltextDBConfiguration = {
7897
fulltextAdapter: {
79-
factory: createElasticAdapter,
98+
factory: fulltextFactory,
8099
url: fullTextDbURL
81100
},
82101
contentAdapters: {
@@ -89,11 +108,7 @@ const config: FulltextDBConfiguration = {
89108
defaultContentAdapter: 'Rekoni'
90109
}
91110

92-
const elasticIndexName = process.env.ELASTIC_INDEX_NAME
93-
if (elasticIndexName === undefined) {
94-
console.log('Please provide ELASTIC_INDEX_NAME')
95-
process.exit(1)
96-
}
111+
const elasticIndexName = process.env.ELASTIC_INDEX_NAME ?? 'huly_storage_index'
97112

98113
const servicePort = parseInt(process.env.PORT ?? '4700')
99114
metricsContext.info('Starting stats service')

rush.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,16 @@
547547
"projectFolder": "foundations/server/packages/elastic",
548548
"shouldPublish": true
549549
},
550+
{
551+
"packageName": "@hcengineering/opensearch",
552+
"projectFolder": "foundations/server/packages/opensearch",
553+
"shouldPublish": true
554+
},
555+
{
556+
"packageName": "@hcengineering/typesense",
557+
"projectFolder": "foundations/server/packages/typesense",
558+
"shouldPublish": true
559+
},
550560
{
551561
"packageName": "@hcengineering/kafka",
552562
"projectFolder": "foundations/server/packages/kafka",

0 commit comments

Comments
 (0)