Skip to content

Commit 3336eec

Browse files
committed
added ClearScroll(scrollId) extension method
1 parent 3dc8290 commit 3336eec

File tree

2 files changed

+58
-3
lines changed

2 files changed

+58
-3
lines changed

src/Nest/ConvenienceExtensions/ScrollExtensions.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Threading.Tasks;
1+
using System.Threading.Tasks;
22

33
namespace Nest
44
{
@@ -38,5 +38,25 @@ public static Task<ISearchResponse<T>> ScrollAsync<T>(this IElasticClient client
3838
{
3939
return client.ScrollAsync<T>(s => s.Scroll(scrollTime).ScrollId(scrollId));
4040
}
41+
42+
/// <summary>
43+
/// Deletes a registered scroll request on the cluster
44+
/// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-scroll.html
45+
/// </summary>
46+
/// <param name="selector">Specify the scroll id as well as request specific configuration</param>
47+
public static IEmptyResponse ClearScroll(this IElasticClient client, string scrollId)
48+
{
49+
return client.ClearScroll(s => s.ScrollId(scrollId));
50+
}
51+
52+
/// <summary>
53+
/// Deletes a registered scroll request on the cluster
54+
/// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-scroll.html
55+
/// </summary>
56+
/// <param name="selector">Specify the scroll id as well as request specific configuration</param>
57+
public static Task<IEmptyResponse> ClearScrollAsync(this IElasticClient client, string scrollId)
58+
{
59+
return client.ClearScroll(s => s.ScrollId(scrollId));
60+
}
4161
}
4262
}

src/Nest/IElasticClient.cs

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,33 @@ public interface IElasticClient
2020
/// <returns>An IObservable you can subscribe to to listen to the progress of the reindexation process</returns>
2121
IObservable<IReindexResponse<T>> Reindex<T>(Func<ReindexDescriptor<T>, ReindexDescriptor<T>> reindexSelector)
2222
where T : class;
23+
24+
/// <summary>
25+
/// A search request can be scrolled by specifying the scroll parameter.
26+
/// <para>The scroll parameter is a time value parameter (for example: scroll=5m),
27+
/// indicating for how long the nodes that participate in the search will maintain relevant resources in
28+
/// order to continue and support it.</para><para>
29+
/// This is very similar in its idea to opening a cursor against a database.</para>
30+
/// <para> </para><para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-scroll.html</para>
31+
/// </summary>
32+
/// <typeparam name="T">The type that represents the result hits</typeparam>
33+
/// <param name="scrollSelector">A descriptor that describes the scroll operation</param>
34+
/// <returns>A query response holding T hits as well as the ScrollId for the next scroll operation</returns>
35+
ISearchResponse<T> Scroll<T>(Func<ScrollDescriptor<T>, ScrollDescriptor<T>> scrollSelector)
36+
where T : class;
37+
38+
/// <summary>
39+
/// A search request can be scrolled by specifying the scroll parameter.
40+
/// <para>The scroll parameter is a time value parameter (for example: scroll=5m),
41+
/// indicating for how long the nodes that participate in the search will maintain relevant resources in
42+
/// order to continue and support it.</para><para>
43+
/// This is very similar in its idea to opening a cursor against a database.</para>
44+
/// </summary>
45+
/// <typeparam name="T">The type that represents the result hits</typeparam>
46+
/// <param name="scrollSelector">A descriptor that describes the scroll operation</param>
47+
/// <returns>A query response holding T hits as well as the ScrollId for the next scroll operation</returns>
48+
Task<ISearchResponse<T>> ScrollAsync<T>(Func<ScrollDescriptor<T>, ScrollDescriptor<T>> scrollSelector)
49+
where T : class;
2350

2451
/// <summary>
2552
/// The update API allows to update a document based on a script provided.
@@ -982,10 +1009,18 @@ ISuggestResponse Suggest<T>(Func<SuggestDescriptor<T>, SuggestDescriptor<T>> sel
9821009
Task<ISuggestResponse> SuggestAsync<T>(Func<SuggestDescriptor<T>, SuggestDescriptor<T>> selector)
9831010
where T : class;
9841011

985-
/// <inheritdoc />
1012+
/// <summary>
1013+
/// Deletes a registered scroll request on the cluster
1014+
/// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-scroll.html
1015+
/// </summary>
1016+
/// <param name="selector">Specify the scroll id as well as request specific configuration</param>
9861017
IEmptyResponse ClearScroll(Func<ClearScrollDescriptor, ClearScrollDescriptor> clearScrollSelector);
9871018

988-
/// <inheritdoc />
1019+
/// <summary>
1020+
/// Deletes a registered scroll request on the cluster
1021+
/// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-scroll.html
1022+
/// </summary>
1023+
/// <param name="selector">Specify the scroll id as well as request specific configuration</param>
9891024
Task<IEmptyResponse> ClearScrollAsync(Func<ClearScrollDescriptor, ClearScrollDescriptor> clearScrollSelector);
9901025
}
9911026
}

0 commit comments

Comments
 (0)