diff --git a/server/multitenancy/tenant_index.ts b/server/multitenancy/tenant_index.ts index 739de26b0..a9de653db 100644 --- a/server/multitenancy/tenant_index.ts +++ b/server/multitenancy/tenant_index.ts @@ -39,11 +39,11 @@ export async function setupIndexTemplate( ) { const mappings: IndexMapping = buildActiveMappings(mergeTypes(typeRegistry.getAllTypes())); try { - await esClient.indices.putTemplate({ + await esClient.indices.putIndexTemplate({ name: 'tenant_template', body: { - // Setting order to the max value to avoid being overridden by custom templates. - order: MAX_INTEGER, + // Setting priority to the max value to avoid being overridden by custom index templates. + priority: MAX_INTEGER, index_patterns: [ opensearchDashboardsIndex + '_-*_*', opensearchDashboardsIndex + '_0*_*', @@ -57,10 +57,12 @@ export async function setupIndexTemplate( opensearchDashboardsIndex + '_8*_*', opensearchDashboardsIndex + '_9*_*', ], - settings: { - number_of_shards: 1, + template: { + settings: { + number_of_shards: 1, + }, + mappings, }, - mappings, }, }); } catch (error) { diff --git a/server/multitenancy/test/tenant_index.test.ts b/server/multitenancy/test/tenant_index.test.ts index cc295f787..0ef517661 100644 --- a/server/multitenancy/test/tenant_index.test.ts +++ b/server/multitenancy/test/tenant_index.test.ts @@ -18,26 +18,27 @@ import { MAX_INTEGER } from '../../../common'; describe('Tenant index template', () => { const mockOpenSearchClient = { indices: { - putTemplate: jest.fn().mockImplementation((template) => { + putIndexTemplate: jest.fn().mockImplementation((template) => { return template; }), }, }; - const order = MAX_INTEGER; + const priority = MAX_INTEGER; - it('put template', () => { - const result = mockOpenSearchClient.indices.putTemplate({ + it('put index template', () => { + const result = mockOpenSearchClient.indices.putIndexTemplate({ name: 'test_index_template_a', body: { - order, + priority, index_patterns: 'test_index_patterns_a', - mappings: { - dynamic: 'strict', - properties: { baz: { type: 'text' } }, + template: { + settings: { + number_of_shards: 1, + }, }, }, }); - expect(result.body.order).toEqual(order); + expect(result.body.priority).toEqual(priority); }); });