diff --git a/apps/app/src/server/service/search-delegator/elasticsearch.ts b/apps/app/src/server/service/search-delegator/elasticsearch.ts index 8f956227189..e49f7875cf0 100644 --- a/apps/app/src/server/service/search-delegator/elasticsearch.ts +++ b/apps/app/src/server/service/search-delegator/elasticsearch.ts @@ -435,7 +435,20 @@ class ElasticsearchDelegator }); } } - + async createAuditlogIndex(index: string) { + if (isES7ClientDelegator(this.client)) { + const { mappings } = await import('./mappings/mappings-auditlog-es7'); + return this.client.indices.create({ index, body: { ...mappings } }); + } + if (isES8ClientDelegator(this.client)) { + const { mappings } = await import('./mappings/mappings-auditlog-es8'); + return this.client.indices.create({ index, ...mappings }); + } + if (isES9ClientDelegator(this.client)) { + const { mappings } = await import('./mappings/mappings-auditlog-es9'); + return this.client.indices.create({ index, ...mappings }); + } + } /** * generate object that is related to page.grant* */ diff --git a/apps/app/src/server/service/search-delegator/mappings/mappings-auditlog-es7.ts b/apps/app/src/server/service/search-delegator/mappings/mappings-auditlog-es7.ts new file mode 100644 index 00000000000..6e0efd4879c --- /dev/null +++ b/apps/app/src/server/service/search-delegator/mappings/mappings-auditlog-es7.ts @@ -0,0 +1,13 @@ +import type { estypes } from '@elastic/elasticsearch7'; + +type Mappings = { + mappings: estypes.MappingTypeMapping; +}; + +export const mappings: Mappings = { + mappings: { + properties: { + username: { type: 'keyword' }, + }, + }, +}; diff --git a/apps/app/src/server/service/search-delegator/mappings/mappings-auditlog-es8.ts b/apps/app/src/server/service/search-delegator/mappings/mappings-auditlog-es8.ts new file mode 100644 index 00000000000..0ef553b091c --- /dev/null +++ b/apps/app/src/server/service/search-delegator/mappings/mappings-auditlog-es8.ts @@ -0,0 +1,13 @@ +import type { estypes } from '@elastic/elasticsearch8'; + +type Mappings = { + mappings: estypes.IndicesCreateRequest['mappings']; +}; + +export const mappings: Mappings = { + mappings: { + properties: { + username: { type: 'keyword' }, + }, + }, +}; diff --git a/apps/app/src/server/service/search-delegator/mappings/mappings-auditlog-es9.ts b/apps/app/src/server/service/search-delegator/mappings/mappings-auditlog-es9.ts new file mode 100644 index 00000000000..d61f17ee6ec --- /dev/null +++ b/apps/app/src/server/service/search-delegator/mappings/mappings-auditlog-es9.ts @@ -0,0 +1,13 @@ +import type { estypes } from '@elastic/elasticsearch9'; + +type Mappings = { + mappings: estypes.IndicesCreateRequest['mappings']; +}; + +export const mappings: Mappings = { + mappings: { + properties: { + username: { type: 'keyword' }, + }, + }, +};