mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-27 20:14:57 +02:00
tool for reindexing elasticsearch db (#5643)
Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
This commit is contained in:
@@ -22,7 +22,8 @@ import core, {
|
||||
type Tx,
|
||||
type WorkspaceId,
|
||||
type Ref,
|
||||
type Doc
|
||||
type Doc,
|
||||
DOMAIN_DOC_INDEX_STATE
|
||||
} from '@hcengineering/core'
|
||||
import { getWorkspaceDB } from '@hcengineering/mongo'
|
||||
import { MongoClient } from 'mongodb'
|
||||
@@ -97,3 +98,25 @@ export async function updateField (
|
||||
await connection.close()
|
||||
}
|
||||
}
|
||||
|
||||
export async function recreateElastic (
|
||||
mongoUrl: string,
|
||||
workspaceId: WorkspaceId,
|
||||
transactorUrl: string
|
||||
): Promise<void> {
|
||||
const client = new MongoClient(mongoUrl)
|
||||
const connection = (await connect(transactorUrl, workspaceId, undefined, {
|
||||
mode: 'backup'
|
||||
})) as unknown as CoreClient & BackupClient
|
||||
try {
|
||||
await client.connect()
|
||||
const db = getWorkspaceDB(client, workspaceId)
|
||||
await db
|
||||
.collection(DOMAIN_DOC_INDEX_STATE)
|
||||
.updateMany({ _class: core.class.DocIndexState }, { $set: { stages: {} } })
|
||||
await connection.sendForceClose()
|
||||
} finally {
|
||||
await client.close()
|
||||
await connection.close()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user