Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qfix: elastic adapter index not found exception #5482

Merged
merged 3 commits into from
Apr 26, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions server/elastic/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,17 @@ class ElasticAdapter implements FullTextAdapter {
const indexName = this.indexName
const result: Record<string, number> = {}
try {
const existingBaseIndices = await this.client.indices.get({
index: [this.indexBaseName, `${this.indexBaseName}_*`]
const baseIndexExists = await this.client.indices.exists({
index: this.indexBaseName
})
const existingOldVersionIndices = Object.keys(existingBaseIndices.body).filter((name) => name !== indexName)
const existingVersions = await this.client.indices.get({
index: [`${this.indexBaseName}_*`]
})
const existingOldVersionIndices = Object.keys(existingVersions.body).filter((name) => name !== indexName)
if (baseIndexExists.body) {
existingOldVersionIndices.push(this.indexBaseName)
}

if (existingOldVersionIndices.length > 0) {
await this.client.indices.delete({
index: existingOldVersionIndices
Expand Down Expand Up @@ -146,7 +153,7 @@ class ElasticAdapter implements FullTextAdapter {
}
if (k === 'workspaceId') {
if (va?.type !== 'keyword') {
this.metrics().info('Force index-recreate, since wrong index type was used')
void this.metrics().info('Force index-recreate, since wrong index type was used')
await this.client.indices.delete({
index: indexName
})
Expand Down
Loading