Skip to content

Commit 3870f59

Browse files
russcamStuart Cam
authored and
Stuart Cam
committed
Add Settings, Aliases and Mappings to RollOverIndexRequest (#2969)
Closes #2879
1 parent 65bc7d7 commit 3870f59

File tree

2 files changed

+105
-1
lines changed

2 files changed

+105
-1
lines changed

src/Nest/Indices/IndexManagement/RolloverIndex/RolloverIndexRequest.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace Nest
99
{
1010
[JsonConverter(typeof(ReadAsTypeJsonConverter<RolloverIndexRequest>))]
11-
public partial interface IRolloverIndexRequest
11+
public partial interface IRolloverIndexRequest : IIndexState
1212
{
1313
[JsonProperty("conditions")]
1414
IRolloverConditions Conditions { get; set; }
@@ -17,14 +17,32 @@ public partial interface IRolloverIndexRequest
1717
public partial class RolloverIndexRequest
1818
{
1919
public IRolloverConditions Conditions { get; set; }
20+
21+
public IIndexSettings Settings { get; set; }
22+
23+
public IAliases Aliases { get; set; }
24+
25+
public IMappings Mappings { get; set; }
2026
}
2127

2228
[DescriptorFor("IndicesRollover")]
2329
public partial class RolloverIndexDescriptor
2430
{
2531
IRolloverConditions IRolloverIndexRequest.Conditions { get; set; }
32+
IIndexSettings IIndexState.Settings { get; set; }
33+
IMappings IIndexState.Mappings { get; set; }
34+
IAliases IIndexState.Aliases { get; set; }
2635

2736
public RolloverIndexDescriptor Conditions(Func<RolloverConditionsDescriptor, IRolloverConditions> selector) =>
2837
Assign(a => a.Conditions = selector?.Invoke(new RolloverConditionsDescriptor()));
38+
39+
public RolloverIndexDescriptor Settings(Func<IndexSettingsDescriptor, IPromise<IIndexSettings>> selector) =>
40+
Assign(a => a.Settings = selector?.Invoke(new IndexSettingsDescriptor())?.Value);
41+
42+
public RolloverIndexDescriptor Mappings(Func<MappingsDescriptor, IPromise<IMappings>> selector) =>
43+
Assign(a => a.Mappings = selector?.Invoke(new MappingsDescriptor())?.Value);
44+
45+
public RolloverIndexDescriptor Aliases(Func<AliasesDescriptor, IPromise<IAliases>> selector) =>
46+
Assign(a => a.Aliases = selector?.Invoke(new AliasesDescriptor())?.Value);
2947
}
3048
}

src/Tests/Indices/IndexManagement/RolloverIndex/RolloverIndexApiTests.cs

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Tests.Framework;
1010
using Tests.Framework.Integration;
1111
using Tests.Framework.ManagedElasticsearch.Clusters;
12+
using Tests.Framework.MockData;
1213

1314
namespace Tests.Indices.IndexManagement.RolloverIndex
1415
{
@@ -53,6 +54,36 @@ protected override LazyResponses ClientUsage() => Calls(
5354
{
5455
max_age = "7d",
5556
max_docs = 1000
57+
},
58+
settings = new Dictionary<string, object>
59+
{
60+
{ "index.number_of_shards", 1 },
61+
{ "index.number_of_replicas", 1 }
62+
},
63+
mappings = new
64+
{
65+
doc = new
66+
{
67+
properties = new
68+
{
69+
branches = new
70+
{
71+
type = "text",
72+
fields = new
73+
{
74+
keyword = new
75+
{
76+
type = "keyword",
77+
ignore_above = 256
78+
}
79+
}
80+
}
81+
}
82+
}
83+
},
84+
aliases = new
85+
{
86+
new_projects = new {}
5687
}
5788
};
5889

@@ -62,6 +93,39 @@ protected override LazyResponses ClientUsage() => Calls(
6293
{
6394
MaxAge = "7d",
6495
MaxDocs = 1000
96+
},
97+
Settings = new Nest.IndexSettings
98+
{
99+
NumberOfShards = 1,
100+
NumberOfReplicas = 1
101+
},
102+
Mappings = new Mappings
103+
{
104+
{ typeof(Project), new TypeMapping
105+
{
106+
Properties = new Properties<Project>
107+
{
108+
{
109+
p => p.Branches, new TextProperty
110+
{
111+
Fields = new Properties
112+
{
113+
{
114+
"keyword", new KeywordProperty
115+
{
116+
IgnoreAbove = 256
117+
}
118+
}
119+
}
120+
}
121+
}
122+
}
123+
}
124+
}
125+
},
126+
Aliases = new Aliases
127+
{
128+
{ "new_projects", new Alias() }
65129
}
66130
};
67131

@@ -70,6 +134,28 @@ protected override LazyResponses ClientUsage() => Calls(
70134
.Conditions(c => c
71135
.MaxAge("7d")
72136
.MaxDocs(1000)
137+
)
138+
.Settings(s => s
139+
.NumberOfShards(1)
140+
.NumberOfReplicas(1)
141+
)
142+
.Mappings(m => m
143+
.Map<Project>(p => p
144+
.Properties(pp => pp
145+
.Text(t => t
146+
.Name(n => n.Branches)
147+
.Fields(pf => pf
148+
.Keyword(k => k
149+
.Name("keyword")
150+
.IgnoreAbove(256)
151+
)
152+
)
153+
)
154+
)
155+
)
156+
)
157+
.Aliases(a => a
158+
.Alias("new_projects")
73159
);
74160

75161
protected override void ExpectResponse(IRolloverIndexResponse response)

0 commit comments

Comments
 (0)