Skip to content

Commit d640bc3

Browse files
committed
Add settings to create follow index and create auto follow pattern APIs
Relates: elastic/elasticsearch#58103
1 parent f4693ed commit d640bc3

File tree

7 files changed

+90
-6
lines changed

7 files changed

+90
-6
lines changed

src/Nest/XPack/CrossClusterReplication/AutoFollow/CreateAutoFollowPattern/CreateAutoFollowPatternRequest.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
33
// See the LICENSE file in the project root for more information
44

5-
using System.Collections.Generic;
5+
using System;
6+
using System.Collections.Generic;
67

78
namespace Nest
89
{
@@ -22,6 +23,8 @@ public partial class CreateAutoFollowPatternRequest
2223
public string RemoteCluster { get; set; }
2324
/// <inheritdoc cref="IAutoFollowPattern.LeaderIndexPatterns"/>
2425
public IEnumerable<string> LeaderIndexPatterns { get; set; }
26+
/// <inheritdoc cref="IAutoFollowPattern.Settings"/>
27+
public IIndexSettings Settings { get; set; }
2528
/// <inheritdoc cref="IAutoFollowPattern.FollowIndexPattern"/>
2629
public string FollowIndexPattern { get; set; }
2730
/// <inheritdoc cref="IAutoFollowPattern.MaxReadRequestOperationCount"/>
@@ -52,6 +55,7 @@ public partial class CreateAutoFollowPatternDescriptor
5255
string IAutoFollowPattern.RemoteCluster { get; set; }
5356
IEnumerable<string> IAutoFollowPattern.LeaderIndexPatterns { get; set; }
5457
string IAutoFollowPattern.FollowIndexPattern { get; set; }
58+
IIndexSettings IAutoFollowPattern.Settings { get; set; }
5559
int? IAutoFollowPattern.MaxReadRequestOperationCount { get; set; }
5660
long? IAutoFollowPattern.MaxOutstandingReadRequests { get; set; }
5761
string IAutoFollowPattern.MaxReadRequestSize { get; set; }
@@ -78,6 +82,10 @@ public CreateAutoFollowPatternDescriptor LeaderIndexPatterns(params string[] lea
7882
public CreateAutoFollowPatternDescriptor FollowIndexPattern(string followIndexPattern) =>
7983
Assign(followIndexPattern, (a, v) => a.FollowIndexPattern = v);
8084

85+
/// <inheritdoc cref="IAutoFollowPattern.Settings"/>
86+
public CreateAutoFollowPatternDescriptor Settings(Func<IndexSettingsDescriptor, IPromise<IIndexSettings>> selector) =>
87+
Assign(selector, (a, v) => a.Settings = v?.Invoke(new IndexSettingsDescriptor())?.Value);
88+
8189
/// <inheritdoc cref="IAutoFollowPattern.MaxReadRequestOperationCount"/>
8290
public CreateAutoFollowPatternDescriptor MaxReadRequestOperationCount(int? maxReadRequestOperationCount) =>
8391
Assign(maxReadRequestOperationCount, (a, v) => a.MaxReadRequestOperationCount = v);

src/Nest/XPack/CrossClusterReplication/AutoFollow/GetAutoFollowPattern/GetAutoFollowPatternResponse.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,15 @@ public interface IAutoFollowPattern
109109
[DataMember(Name = "leader_index_patterns")]
110110
IEnumerable<string> LeaderIndexPatterns { get; set; }
111111

112+
/// <summary>
113+
/// Settings to override from the leader index.
114+
/// Note that certain settings can not be overrode e.g. index.number_of_shards.
115+
/// <para />
116+
/// Valid in Elasticsearch 7.9.0+
117+
/// </summary>
118+
[DataMember(Name ="settings")]
119+
IIndexSettings Settings { get; set; }
120+
112121
/// <summary>
113122
/// the maximum number of outstanding reads requests from the remote cluster
114123
/// </summary>
@@ -189,6 +198,9 @@ public class AutoFollowPattern : IAutoFollowPattern
189198
/// <inheritdoc cref="IAutoFollowPattern.LeaderIndexPatterns" />
190199
public IEnumerable<string> LeaderIndexPatterns { get; set; }
191200

201+
/// <inheritdoc cref="IAutoFollowPattern.Settings" />
202+
public IIndexSettings Settings { get; set; }
203+
192204
/// <inheritdoc cref="IAutoFollowPattern.MaxOutstandingReadRequests" />
193205
public long? MaxOutstandingReadRequests { get; set; }
194206

src/Nest/XPack/CrossClusterReplication/Follow/CreateFollowIndex/CreateFollowIndexRequest.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
33
// See the LICENSE file in the project root for more information
44

5-
using System.Runtime.Serialization;
5+
using System;
6+
using System.Runtime.Serialization;
67

78
namespace Nest
89
{
@@ -22,6 +23,15 @@ public partial interface ICreateFollowIndexRequest
2223
[DataMember(Name = "leader_index")]
2324
IndexName LeaderIndex { get; set; }
2425

26+
/// <summary>
27+
/// Settings to override from the leader index.
28+
/// Note that certain settings can not be overrode e.g. index.number_of_shards.
29+
/// <para />
30+
/// Valid in Elasticsearch 7.9.0+
31+
/// </summary>
32+
[DataMember(Name ="settings")]
33+
IIndexSettings Settings { get; set; }
34+
2535
/// <summary>the maximum number of operations to pull per read from the remote cluster </summary>
2636
[DataMember(Name = "max_read_request_operation_count")]
2737
long? MaxReadRequestOperationCount { get; set; }
@@ -85,6 +95,9 @@ public partial class CreateFollowIndexRequest
8595
/// <inheritdoc cref="ICreateFollowIndexRequest.LeaderIndex"/>
8696
public IndexName LeaderIndex { get; set; }
8797

98+
/// <inheritdoc cref="ICreateFollowIndexRequest.Settings"/>
99+
public IIndexSettings Settings { get; set; }
100+
88101
/// <inheritdoc cref="ICreateFollowIndexRequest.MaxReadRequestOperationCount"/>
89102
public long? MaxReadRequestOperationCount { get; set; }
90103

@@ -121,6 +134,7 @@ public partial class CreateFollowIndexDescriptor
121134
{
122135
string ICreateFollowIndexRequest.RemoteCluster { get; set; }
123136
IndexName ICreateFollowIndexRequest.LeaderIndex { get; set; }
137+
IIndexSettings ICreateFollowIndexRequest.Settings { get; set; }
124138
long? ICreateFollowIndexRequest.MaxReadRequestOperationCount { get; set; }
125139
long? ICreateFollowIndexRequest.MaxOutstandingReadRequests { get; set; }
126140
string ICreateFollowIndexRequest.MaxRequestSize { get; set; }
@@ -138,6 +152,10 @@ public partial class CreateFollowIndexDescriptor
138152
/// <inheritdoc cref="ICreateFollowIndexRequest.LeaderIndex"/>
139153
public CreateFollowIndexDescriptor LeaderIndex(IndexName index) => Assign(index, (a, v) => a.LeaderIndex = v);
140154

155+
/// <inheritdoc cref="ICreateFollowIndexRequest.Settings"/>
156+
public CreateFollowIndexDescriptor Settings(Func<IndexSettingsDescriptor, IPromise<IIndexSettings>> selector) =>
157+
Assign(selector, (a, v) => a.Settings = v?.Invoke(new IndexSettingsDescriptor())?.Value);
158+
141159
/// <inheritdoc cref="ICreateFollowIndexRequest.MaxReadRequestOperationCount"/>
142160
public CreateFollowIndexDescriptor MaxReadRequestOperationCount(long? max) => Assign(max, (a, v) => a.MaxReadRequestOperationCount = v);
143161

tests/Tests/XPack/CrossClusterReplication/AutoFollow/CreateAutoFollowPattern/CreateAutoFollowPatternApiTests.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
// See the LICENSE file in the project root for more information
44

55
using System;
6-
using Elasticsearch.Net;
6+
using System.Collections.Generic;
7+
using Elasticsearch.Net;
78
using Nest;
89
using Tests.Core.ManagedElasticsearch.Clusters;
910
using Tests.Framework.EndpointTests;
@@ -19,6 +20,10 @@ public CreateAutoFollowPatternApiTests(XPackCluster cluster, EndpointUsage usage
1920
{
2021
follow_index_pattern = "y",
2122
leader_index_patterns = new [] { "z" },
23+
settings = new Dictionary<string, object>
24+
{
25+
["index.queries.cache.enabled"] = false
26+
},
2227
max_outstanding_read_requests = 100,
2328
max_outstanding_write_requests = 101,
2429
max_read_request_operation_count = 102,
@@ -38,6 +43,13 @@ public CreateAutoFollowPatternApiTests(XPackCluster cluster, EndpointUsage usage
3843
.RemoteCluster("x")
3944
.FollowIndexPattern("y")
4045
.LeaderIndexPatterns("z")
46+
.Settings(s => s
47+
.Queries(q => q
48+
.Cache(qc => qc
49+
.Enabled(false)
50+
)
51+
)
52+
)
4153
.MaxWriteBufferSize("1mb")
4254
.MaxOutstandingReadRequests(100)
4355
.MaxOutstandingWriteRequests( 101)
@@ -57,6 +69,16 @@ public CreateAutoFollowPatternApiTests(XPackCluster cluster, EndpointUsage usage
5769
RemoteCluster = "x",
5870
FollowIndexPattern = "y",
5971
LeaderIndexPatterns = new []{"z"},
72+
Settings = new IndexSettings
73+
{
74+
Queries = new QueriesSettings
75+
{
76+
Cache = new QueriesCacheSettings
77+
{
78+
Enabled = false
79+
}
80+
}
81+
},
6082
MaxWriteBufferSize = "1mb",
6183
MaxOutstandingReadRequests = 100,
6284
MaxOutstandingWriteRequests = 101,

tests/Tests/XPack/CrossClusterReplication/AutoFollow/CreateAutoFollowPattern/CreateAutoFollowPatternUrlTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Elastic.Elasticsearch.Xunit.XunitPlumbing;
77
using Nest;
88
using Tests.Framework.EndpointTests;
9+
using static Tests.Framework.EndpointTests.UrlTester;
910

1011
namespace Tests.XPack.CrossClusterReplication.AutoFollow.CreateAutoFollowPattern
1112
{
@@ -14,7 +15,7 @@ public class CreateAutoFollowPatternUrlTests : UrlTestsBase
1415
[U] public override async Task Urls()
1516
{
1617
var name = "x";
17-
await UrlTester.PUT($"/_ccr/auto_follow/{name}")
18+
await PUT($"/_ccr/auto_follow/{name}")
1819
.Fluent(c => c.CrossClusterReplication.CreateAutoFollowPattern(name, d => d))
1920
.Request(c => c.CrossClusterReplication.CreateAutoFollowPattern(new CreateAutoFollowPatternRequest(name)))
2021
.FluentAsync(c => c.CrossClusterReplication.CreateAutoFollowPatternAsync(name, d => d))

tests/Tests/XPack/CrossClusterReplication/Follow/CreateFollowIndex/CreateFollowIndexApiTests.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
// See the LICENSE file in the project root for more information
44

55
using System;
6-
using Elasticsearch.Net;
6+
using System.Collections.Generic;
7+
using Elasticsearch.Net;
78
using Nest;
89
using Tests.Core.ManagedElasticsearch.Clusters;
910
using Tests.Framework.EndpointTests;
@@ -18,6 +19,10 @@ public CreateFollowIndexApiTests(XPackCluster cluster, EndpointUsage usage) : ba
1819
protected override object ExpectJson { get; } = new
1920
{
2021
leader_index = "leader",
22+
settings = new Dictionary<string, object>
23+
{
24+
["index.queries.cache.enabled"] = false
25+
},
2126
max_outstanding_read_requests = 100,
2227
max_outstanding_write_requests = 101,
2328
max_read_request_operation_count = 102,
@@ -46,6 +51,13 @@ public CreateFollowIndexApiTests(XPackCluster cluster, EndpointUsage usage) : ba
4651
.MaxRequestSize("4mb")
4752
.ReadPollTimeout("2m")
4853
.LeaderIndex("leader")
54+
.Settings(s => s
55+
.Queries(q => q
56+
.Cache(qc => qc
57+
.Enabled(false)
58+
)
59+
)
60+
)
4961
;
5062

5163
protected override HttpMethod HttpMethod => HttpMethod.PUT;
@@ -64,6 +76,16 @@ public CreateFollowIndexApiTests(XPackCluster cluster, EndpointUsage usage) : ba
6476
MaxRequestSize = "4mb",
6577
ReadPollTimeout = "2m",
6678
LeaderIndex = "leader",
79+
Settings = new IndexSettings
80+
{
81+
Queries = new QueriesSettings
82+
{
83+
Cache = new QueriesCacheSettings
84+
{
85+
Enabled = false
86+
}
87+
}
88+
},
6789
};
6890

6991
protected override bool SupportsDeserialization => false;

tests/Tests/XPack/CrossClusterReplication/Follow/CreateFollowIndex/CreateFollowIndexUrlTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Elastic.Elasticsearch.Xunit.XunitPlumbing;
77
using Nest;
88
using Tests.Framework.EndpointTests;
9+
using static Tests.Framework.EndpointTests.UrlTester;
910

1011
namespace Tests.XPack.CrossClusterReplication.Follow.CreateFollowIndex
1112
{
@@ -14,7 +15,7 @@ public class CreateFollowIndexUrlTests : UrlTestsBase
1415
[U] public override async Task Urls()
1516
{
1617
var name = "x";
17-
await UrlTester.PUT($"/{name}/_ccr/follow")
18+
await PUT($"/{name}/_ccr/follow")
1819
.Fluent(c => c.CrossClusterReplication.CreateFollowIndex(name, d => d))
1920
.Request(c => c.CrossClusterReplication.CreateFollowIndex(new CreateFollowIndexRequest(name)))
2021
.FluentAsync(c => c.CrossClusterReplication.CreateFollowIndexAsync(name, d => d))

0 commit comments

Comments
 (0)