diff --git a/src/Nest/Indices/IndexManagement/RolloverIndex/RolloverIndexRequest.cs b/src/Nest/Indices/IndexManagement/RolloverIndex/RolloverIndexRequest.cs index 1b136074a6d..f50d976b308 100644 --- a/src/Nest/Indices/IndexManagement/RolloverIndex/RolloverIndexRequest.cs +++ b/src/Nest/Indices/IndexManagement/RolloverIndex/RolloverIndexRequest.cs @@ -8,7 +8,7 @@ namespace Nest { [JsonConverter(typeof(ReadAsTypeJsonConverter))] - public partial interface IRolloverIndexRequest + public partial interface IRolloverIndexRequest : IIndexState { [JsonProperty("conditions")] IRolloverConditions Conditions { get; set; } @@ -17,14 +17,32 @@ public partial interface IRolloverIndexRequest public partial class RolloverIndexRequest { public IRolloverConditions Conditions { get; set; } + + public IIndexSettings Settings { get; set; } + + public IAliases Aliases { get; set; } + + public IMappings Mappings { get; set; } } [DescriptorFor("IndicesRollover")] public partial class RolloverIndexDescriptor { IRolloverConditions IRolloverIndexRequest.Conditions { get; set; } + IIndexSettings IIndexState.Settings { get; set; } + IMappings IIndexState.Mappings { get; set; } + IAliases IIndexState.Aliases { get; set; } public RolloverIndexDescriptor Conditions(Func selector) => Assign(a => a.Conditions = selector?.Invoke(new RolloverConditionsDescriptor())); + + public RolloverIndexDescriptor Settings(Func> selector) => + Assign(a => a.Settings = selector?.Invoke(new IndexSettingsDescriptor())?.Value); + + public RolloverIndexDescriptor Mappings(Func> selector) => + Assign(a => a.Mappings = selector?.Invoke(new MappingsDescriptor())?.Value); + + public RolloverIndexDescriptor Aliases(Func> selector) => + Assign(a => a.Aliases = selector?.Invoke(new AliasesDescriptor())?.Value); } } diff --git a/src/Tests/Indices/IndexManagement/RolloverIndex/RolloverIndexApiTests.cs b/src/Tests/Indices/IndexManagement/RolloverIndex/RolloverIndexApiTests.cs index 4ad1a8a5688..9670d13ef1e 100644 --- a/src/Tests/Indices/IndexManagement/RolloverIndex/RolloverIndexApiTests.cs +++ b/src/Tests/Indices/IndexManagement/RolloverIndex/RolloverIndexApiTests.cs @@ -9,6 +9,7 @@ using Tests.Framework; using Tests.Framework.Integration; using Tests.Framework.ManagedElasticsearch.Clusters; +using Tests.Framework.MockData; namespace Tests.Indices.IndexManagement.RolloverIndex { @@ -53,6 +54,36 @@ protected override LazyResponses ClientUsage() => Calls( { max_age = "7d", max_docs = 1000 + }, + settings = new Dictionary + { + { "index.number_of_shards", 1 }, + { "index.number_of_replicas", 1 } + }, + mappings = new + { + doc = new + { + properties = new + { + branches = new + { + type = "text", + fields = new + { + keyword = new + { + type = "keyword", + ignore_above = 256 + } + } + } + } + } + }, + aliases = new + { + new_projects = new {} } }; @@ -62,6 +93,39 @@ protected override LazyResponses ClientUsage() => Calls( { MaxAge = "7d", MaxDocs = 1000 + }, + Settings = new Nest.IndexSettings + { + NumberOfShards = 1, + NumberOfReplicas = 1 + }, + Mappings = new Mappings + { + { typeof(Project), new TypeMapping + { + Properties = new Properties + { + { + p => p.Branches, new TextProperty + { + Fields = new Properties + { + { + "keyword", new KeywordProperty + { + IgnoreAbove = 256 + } + } + } + } + } + } + } + } + }, + Aliases = new Aliases + { + { "new_projects", new Alias() } } }; @@ -70,6 +134,28 @@ protected override LazyResponses ClientUsage() => Calls( .Conditions(c => c .MaxAge("7d") .MaxDocs(1000) + ) + .Settings(s => s + .NumberOfShards(1) + .NumberOfReplicas(1) + ) + .Mappings(m => m + .Map(p => p + .Properties(pp => pp + .Text(t => t + .Name(n => n.Branches) + .Fields(pf => pf + .Keyword(k => k + .Name("keyword") + .IgnoreAbove(256) + ) + ) + ) + ) + ) + ) + .Aliases(a => a + .Alias("new_projects") ); protected override void ExpectResponse(IRolloverIndexResponse response)