Skip to content

Commit c5f3ef8

Browse files
Add indices refresh shortcut client methods (#6909) (#6915)
Co-authored-by: Steve Gordon <sgordon@hotmail.co.uk>
1 parent 652f12e commit c5f3ef8

File tree

8 files changed

+48
-11
lines changed

8 files changed

+48
-11
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System.Threading.Tasks;
6+
using System.Threading;
7+
8+
namespace Elastic.Clients.Elasticsearch.IndexManagement;
9+
10+
public partial class IndicesNamespace
11+
{
12+
/// <summary>
13+
/// Refresh one or more indices. A refresh makes recent operations performed on one or more indices available for search. For data streams,
14+
/// the API runs the refresh operation on the stream’s backing indices.
15+
/// </summary>
16+
/// <param name="indices">The index and/or data streams to refresh.</param>
17+
/// <returns>A <see cref="RefreshResponse"/> from the server.</returns>
18+
public RefreshResponse Refresh(Indices indices)
19+
{
20+
var request = new RefreshRequest(indices);
21+
request.BeforeRequest();
22+
return DoRequest<RefreshRequest, RefreshResponse>(request);
23+
}
24+
25+
/// <summary>
26+
/// Refresh one or more indices. A refresh makes recent operations performed on one or more indices available for search. For data streams,
27+
/// the API runs the refresh operation on the stream’s backing indices.
28+
/// </summary>
29+
/// <param name="indices">The index and/or data streams to refresh.</param>
30+
/// <param name="cancellationToken">A <see cref="CancellationToken"/> used to cancel the asynchronous operation.</param>
31+
/// <returns>A <see cref="RefreshResponse"/> from the server.</returns>
32+
public Task<RefreshResponse> RefreshAsync(Indices indices, CancellationToken cancellationToken = default)
33+
{
34+
var request = new RefreshRequest(indices);
35+
request.BeforeRequest();
36+
return DoRequestAsync<RefreshRequest, RefreshResponse>(request, cancellationToken);
37+
}
38+
}

src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.AsyncSearch.g.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#nullable restore
2323
namespace Elastic.Clients.Elasticsearch.AsyncSearch;
24-
public class AsyncSearchNamespace : NamespacedClientProxy
24+
public sealed partial class AsyncSearchNamespace : NamespacedClientProxy
2525
{
2626
internal AsyncSearchNamespace(ElasticsearchClient client) : base(client)
2727
{

src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.Cluster.g.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#nullable restore
2323
namespace Elastic.Clients.Elasticsearch.Cluster;
24-
public class ClusterNamespace : NamespacedClientProxy
24+
public sealed partial class ClusterNamespace : NamespacedClientProxy
2525
{
2626
internal ClusterNamespace(ElasticsearchClient client) : base(client)
2727
{

src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.Eql.g.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#nullable restore
2323
namespace Elastic.Clients.Elasticsearch.Eql;
24-
public class EqlNamespace : NamespacedClientProxy
24+
public sealed partial class EqlNamespace : NamespacedClientProxy
2525
{
2626
internal EqlNamespace(ElasticsearchClient client) : base(client)
2727
{

src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.Indices.g.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#nullable restore
2323
namespace Elastic.Clients.Elasticsearch.IndexManagement;
24-
public class IndicesNamespace : NamespacedClientProxy
24+
public sealed partial class IndicesNamespace : NamespacedClientProxy
2525
{
2626
internal IndicesNamespace(ElasticsearchClient client) : base(client)
2727
{

src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.Sql.g.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#nullable restore
2323
namespace Elastic.Clients.Elasticsearch.Sql;
24-
public class SqlNamespace : NamespacedClientProxy
24+
public sealed partial class SqlNamespace : NamespacedClientProxy
2525
{
2626
internal SqlNamespace(ElasticsearchClient client) : base(client)
2727
{

tests/Tests/Document/Multiple/DeleteByQuery/DeleteByQueryApiTests.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System;
66
using System.Collections.Generic;
77
using System.Linq;
8-
using Elastic.Clients.Elasticsearch.IndexManagement;
98
using Elastic.Clients.Elasticsearch.Mapping;
109
using Elastic.Clients.Elasticsearch.QueryDsl;
1110
using Tests.Core.Extensions;
@@ -91,7 +90,7 @@ protected override void IntegrationSetup(ElasticsearchClient client, CallUniqueV
9190
Client.IndexMany(Project.Projects, index);
9291
var cloneIndex = index + "-clone";
9392
Client.Indices.Create(cloneIndex);
94-
Client.Indices.Refresh(new RefreshRequest(Infer.Index(index).And(cloneIndex)));
93+
Client.Indices.Refresh(Infer.Index(index).And(cloneIndex));
9594
}
9695
}
9796

@@ -102,7 +101,7 @@ protected override LazyResponses ClientUsage() => Calls(
102101
(client, r) => client.DeleteByQueryAsync(r)
103102
);
104103

105-
protected override void OnAfterCall(ElasticsearchClient client) => client.Indices.Refresh(new RefreshRequest(CallIsolatedValue));
104+
protected override void OnAfterCall(ElasticsearchClient client) => client.Indices.Refresh(CallIsolatedValue);
106105

107106
protected override DeleteByQueryRequestDescriptor<Project> NewDescriptor() => new(Indices);
108107

@@ -276,7 +275,7 @@ protected override void ExpectResponse(DeleteByQueryResponse response)
276275

277276
// Since we only executed one slice of the two, some of the documents that
278277
// match the query will still exist.
279-
Client.Indices.Refresh(new RefreshRequest(CallIsolatedValue));
278+
Client.Indices.Refresh(CallIsolatedValue);
280279

281280
var countResponse = Client.Count<Project>(c => c
282281
.Indices(CallIsolatedValue)

tests/Tests/Document/Multiple/DeleteByQueryRethrottle/DeleteByQueryRethrottleApiTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ protected override void IntegrationSetup(ElasticsearchClient client, CallUniqueV
4848
foreach (var callUniqueValue in values)
4949
{
5050
client.IndexMany(Project.Projects, callUniqueValue.Value);
51-
client.Indices.Refresh(new RefreshRequest(callUniqueValue.Value));
51+
client.Indices.Refresh(CallIsolatedValue);
5252
}
5353
}
5454

@@ -62,7 +62,7 @@ protected override LazyResponses ClientUsage() => Calls(
6262
protected override void OnBeforeCall(ElasticsearchClient client)
6363
{
6464
client.IndexMany(Project.Projects, CallIsolatedValue);
65-
client.Indices.Refresh(new RefreshRequest(CallIsolatedValue));
65+
client.Indices.Refresh(CallIsolatedValue);
6666

6767
var deleteByQuery = client.DeleteByQuery<Project>(CallIsolatedValue, u => u
6868
.Conflicts(Conflicts.Proceed)

0 commit comments

Comments
 (0)