UBER-1178: rework indexing fields (#4261)

Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
Co-authored-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Vyacheslav Tumanov
2023-12-27 14:29:30 +07:00
committed by GitHub
co-authored by Andrey Sobolev
parent 66368621a0
commit 689e2d4caa
6 changed files with 56 additions and 39 deletions
+14 -1
View File
@@ -71,7 +71,20 @@ class ElasticAdapter implements FullTextAdapter {
if (field !== undefined) {
console.log('Mapping', mappings.body)
}
const wsMappings = mappings.body[toWorkspaceString(this.workspaceId)]
let wsMappings = mappings.body[toWorkspaceString(this.workspaceId)]
if (Object.keys(wsMappings?.mappings?.properties ?? {}).some((k) => k.includes('->'))) {
await this.client.indices.delete({
index: toWorkspaceString(this.workspaceId)
})
const createIndex = await this.client.indices.create({
index: toWorkspaceString(this.workspaceId)
})
console.log('recreate index', createIndex)
const mappings = await this.client.indices.getMapping({
index: toWorkspaceString(this.workspaceId)
})
wsMappings = mappings.body[toWorkspaceString(this.workspaceId)]
}
// Collect old values.
for (const [k, v] of Object.entries(wsMappings?.mappings?.properties ?? {})) {