diff --git a/src/Nest/Indices/IndexManagement/RolloverIndex/RolloverConditions.cs b/src/Nest/Indices/IndexManagement/RolloverIndex/RolloverConditions.cs
index 7e4ffe66101..1da9e88a334 100644
--- a/src/Nest/Indices/IndexManagement/RolloverIndex/RolloverConditions.cs
+++ b/src/Nest/Indices/IndexManagement/RolloverIndex/RolloverConditions.cs
@@ -35,6 +35,15 @@ public interface IRolloverConditions
///
[DataMember(Name ="max_size")]
string MaxSize { get; set; }
+
+ ///
+ /// The maximum size of the primary shards in the index e.g. "2gb"
+ ///
+ ///
+ /// Valid in Elasticsearch 7.12.0+
+ ///
+ [DataMember(Name = "max_primary_shard_size")]
+ string MaxPrimaryShardSize { get; set; }
}
///
@@ -48,6 +57,9 @@ public class RolloverConditions : IRolloverConditions
///
public string MaxSize { get; set; }
+
+ ///
+ public string MaxPrimaryShardSize { get; set; }
}
///
@@ -57,6 +69,7 @@ public class RolloverConditionsDescriptor
Time IRolloverConditions.MaxAge { get; set; }
long? IRolloverConditions.MaxDocs { get; set; }
string IRolloverConditions.MaxSize { get; set; }
+ string IRolloverConditions.MaxPrimaryShardSize { get; set; }
///
public RolloverConditionsDescriptor MaxAge(Time maxAge) => Assign(maxAge, (a, v) => a.MaxAge = v);
@@ -66,5 +79,8 @@ public class RolloverConditionsDescriptor
///
public RolloverConditionsDescriptor MaxSize(string maxSize) => Assign(maxSize, (a, v) => a.MaxSize = v);
+
+ ///
+ public RolloverConditionsDescriptor MaxPrimaryShardSize(string maxPrimaryShardSize) => Assign(maxPrimaryShardSize, (a, v) => a.MaxPrimaryShardSize = v);
}
}
diff --git a/tests/Tests/Indices/IndexManagement/RolloverIndex/RolloverIndexApiTests.cs b/tests/Tests/Indices/IndexManagement/RolloverIndex/RolloverIndexApiTests.cs
index 9939b88bdd6..2e0de8de766 100644
--- a/tests/Tests/Indices/IndexManagement/RolloverIndex/RolloverIndexApiTests.cs
+++ b/tests/Tests/Indices/IndexManagement/RolloverIndex/RolloverIndexApiTests.cs
@@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
using Elastic.Transport;
+using Elastic.Elasticsearch.Xunit.XunitPlumbing;
using Elasticsearch.Net;
using FluentAssertions;
using Nest;
@@ -167,4 +168,165 @@ protected override void ExpectResponse(RolloverIndexResponse response)
response.Conditions["[max_docs: 1000]"].Should().BeTrue();
}
}
+
+ [SkipVersion("<7.12.0", "Tests all parameters available in 7.12.0 and higher")]
+ public class RolloverIndexApiWithAllParametersTests
+ : ApiIntegrationTestBase
+ {
+ public RolloverIndexApiWithAllParametersTests(WritableCluster cluster, EndpointUsage usage)
+ : base(cluster, usage) { }
+
+ protected override bool ExpectIsValid => true;
+ protected override int ExpectStatusCode => 200;
+ protected override HttpMethod HttpMethod => HttpMethod.POST;
+ protected override bool SupportsDeserialization => false;
+ protected override string UrlPath => $"/{CallIsolatedValue}-alias/_rollover/{CallIsolatedValue}-new";
+
+ protected override object ExpectJson => new
+ {
+ conditions = new
+ {
+ max_age = "7d",
+ max_docs = 1000,
+ max_size = "5gb",
+ max_primary_shard_size = "2gb"
+ },
+ settings = new Dictionary
+ {
+ { "index.number_of_shards", 1 },
+ { "index.number_of_replicas", 1 }
+ },
+ mappings = new
+ {
+ properties = new
+ {
+ branches = new
+ {
+ type = "text",
+ fields = new
+ {
+ keyword = new
+ {
+ type = "keyword",
+ ignore_above = 256
+ }
+ }
+ }
+ }
+ },
+ aliases = new Dictionary
+ {
+ { CallIsolatedValue + "-new_projects", new { } }
+ }
+ };
+
+ protected override Func Fluent => f => f
+ .NewIndex(CallIsolatedValue + "-new")
+ .Conditions(c => c
+ .MaxAge("7d")
+ .MaxDocs(1000)
+ .MaxSize("5gb")
+ .MaxPrimaryShardSize("2gb")
+ )
+ .Settings(s => s
+ .NumberOfShards(1)
+ .NumberOfReplicas(1)
+ )
+ .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(CallIsolatedValue + "-new_projects")
+ );
+
+ protected override RolloverIndexRequest Initializer => new RolloverIndexRequest(CallIsolatedValue + "-alias", CallIsolatedValue + "-new")
+ {
+ Conditions = new RolloverConditions
+ {
+ MaxAge = "7d",
+ MaxDocs = 1000,
+ MaxSize = "5gb",
+ MaxPrimaryShardSize = "2gb"
+ },
+ Settings = new Nest.IndexSettings
+ {
+ NumberOfShards = 1,
+ NumberOfReplicas = 1
+ },
+ Mappings = new TypeMapping
+ {
+ Properties = new Properties
+ {
+ {
+ p => p.Branches, new TextProperty
+ {
+ Fields = new Properties
+ {
+ {
+ "keyword", new KeywordProperty
+ {
+ IgnoreAbove = 256
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ Aliases = new Aliases
+ {
+ { CallIsolatedValue + "-new_projects", new Alias() }
+ }
+ };
+
+ protected override void OnBeforeCall(IElasticClient client)
+ {
+ var create = client.Indices.Create(CallIsolatedValue, c => c
+ .Aliases(a => a
+ .Alias(CallIsolatedValue + "-alias")
+ )
+ );
+ create.ShouldBeValid();
+ var someDocs = client.Bulk(b => b
+ .Index(CallIsolatedValue)
+ .Refresh(Refresh.True)
+ .IndexMany(Project.Generator.Generate(1200))
+ );
+ someDocs.ShouldBeValid();
+
+ }
+
+ protected override LazyResponses ClientUsage() => Calls(
+ (client, f) => client.Indices.Rollover(CallIsolatedValue + "-alias", f),
+ (client, f) => client.Indices.RolloverAsync(CallIsolatedValue + "-alias", f),
+ (client, r) => client.Indices.Rollover(r),
+ (client, r) => client.Indices.RolloverAsync(r)
+ );
+
+ protected override RolloverIndexDescriptor NewDescriptor() => new RolloverIndexDescriptor(CallIsolatedValue + "-alias");
+
+ protected override void ExpectResponse(RolloverIndexResponse response)
+ {
+ response.ShouldBeValid();
+ response.OldIndex.Should().NotBeNullOrEmpty();
+ response.NewIndex.Should().NotBeNullOrEmpty();
+ response.RolledOver.Should().BeTrue();
+ response.ShardsAcknowledged.Should().BeTrue();
+ response.Conditions.Should().NotBeNull().And.HaveCount(4);
+ response.Conditions["[max_age: 7d]"].Should().BeFalse();
+ response.Conditions["[max_docs: 1000]"].Should().BeTrue();
+ response.Conditions["[max_size: 5gb]"].Should().BeFalse();
+ response.Conditions["[max_primary_shard_size: 2gb]"].Should().BeFalse();
+ }
+ }
}