From 520ce0077b0911b4744908f1bc4ff36961b32bb6 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Thu, 9 Jun 2022 12:34:22 +0800 Subject: [PATCH] Add refresh index method --- packages/api/src/elastic/index.ts | 12 ++++++++++++ packages/api/test/db.ts | 6 +++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/api/src/elastic/index.ts b/packages/api/src/elastic/index.ts index 2b0d8a383..1bef4c2a2 100644 --- a/packages/api/src/elastic/index.ts +++ b/packages/api/src/elastic/index.ts @@ -31,3 +31,15 @@ export const initElasticsearch = async (): Promise => { throw e } } + +export const refreshIndex = async (): Promise => { + try { + const { body } = await client.indices.refresh({ + index: INDEX_ALIAS, + }) + console.log('elastic refresh: ', body) + } catch (e) { + console.error('failed to refresh elastic index', e) + throw e + } +} diff --git a/packages/api/test/db.ts b/packages/api/test/db.ts index 944535721..4d9928c82 100644 --- a/packages/api/test/db.ts +++ b/packages/api/test/db.ts @@ -184,9 +184,9 @@ export const createTestLabel = async ( color: string ): Promise