diff --git a/src/server/saved_objects/migrations/core/call_cluster.ts b/src/server/saved_objects/migrations/core/call_cluster.ts index 656b14d18a5a..e9533691d34f 100644 --- a/src/server/saved_objects/migrations/core/call_cluster.ts +++ b/src/server/saved_objects/migrations/core/call_cluster.ts @@ -87,10 +87,8 @@ export interface IndexCreationOpts { body?: { mappings?: IndexMapping; settings?: { - index: { - number_of_shards: string; - number_of_replicas: string; - }; + number_of_shards: number; + auto_expand_replicas: string; }; }; } diff --git a/src/server/saved_objects/migrations/core/elastic_index.test.ts b/src/server/saved_objects/migrations/core/elastic_index.test.ts index 90cc62c3799a..e2a27e7523aa 100644 --- a/src/server/saved_objects/migrations/core/elastic_index.test.ts +++ b/src/server/saved_objects/migrations/core/elastic_index.test.ts @@ -98,7 +98,10 @@ describe('ElasticIndex', () => { test('calls indices.create', async () => { const callCluster = sinon.spy(async (path: string, { body, index }: any) => { expect(path).toEqual('indices.create'); - expect(body).toEqual({ mappings: { foo: 'bar' } }); + expect(body).toEqual({ + mappings: { foo: 'bar' }, + settings: { auto_expand_replicas: '0-1', number_of_shards: 1 }, + }); expect(index).toEqual('.abcd'); }); @@ -248,6 +251,7 @@ describe('ElasticIndex', () => { properties: { foo: 'bar' }, }, }, + settings: { auto_expand_replicas: '0-1', number_of_shards: 1 }, }); expect(arg.index).toEqual('.ze-index'); return true; diff --git a/src/server/saved_objects/migrations/core/elastic_index.ts b/src/server/saved_objects/migrations/core/elastic_index.ts index 2e28ca0ac5b0..8e21964c7d37 100644 --- a/src/server/saved_objects/migrations/core/elastic_index.ts +++ b/src/server/saved_objects/migrations/core/elastic_index.ts @@ -31,6 +31,8 @@ import { AliasAction, CallCluster, IndexMapping, NotFound, RawDoc } from './call // tslint:disable-next-line:no-var-requires const { getTypes } = require('../../../mappings'); +const settings = { number_of_shards: 1, auto_expand_replicas: '0-1' }; + export interface FullIndexInfo { aliases: { [name: string]: object }; exists: boolean; @@ -213,7 +215,7 @@ export async function createIndex( index: string, mappings?: IndexMapping ) { - await callCluster('indices.create', { body: { mappings }, index }); + await callCluster('indices.create', { body: { mappings, settings }, index }); } export async function deleteIndex(callCluster: CallCluster, index: string) { @@ -236,7 +238,7 @@ export async function convertToAlias( batchSize: number ) { await callCluster('indices.create', { - body: { mappings: info.mappings }, + body: { mappings: info.mappings, settings }, index: info.indexName, }); diff --git a/src/server/saved_objects/migrations/core/index_migrator.test.ts b/src/server/saved_objects/migrations/core/index_migrator.test.ts index 51eb3e424c7e..c28f03b5eab1 100644 --- a/src/server/saved_objects/migrations/core/index_migrator.test.ts +++ b/src/server/saved_objects/migrations/core/index_migrator.test.ts @@ -86,6 +86,7 @@ describe('IndexMigrator', () => { }, }, }, + settings: { number_of_shards: 1, auto_expand_replicas: '0-1' }, }, index: '.kibana_1', }); @@ -197,6 +198,7 @@ describe('IndexMigrator', () => { }, }, }, + settings: { number_of_shards: 1, auto_expand_replicas: '0-1' }, }, index: '.kibana_2', });