Skip to content

Commit 09de923

Browse files
Add Scroll APIs (#6334) (#6335)
* Add Scroll APIs Co-authored-by: Steve Gordon <sgordon@hotmail.co.uk>
1 parent 062d26b commit 09de923

File tree

11 files changed

+375
-29
lines changed

11 files changed

+375
-29
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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.Collections.Generic;
6+
using System.Linq;
7+
using System.Text.Json.Serialization;
8+
9+
namespace Elastic.Clients.Elasticsearch.AsyncSearch;
10+
11+
public partial class AsyncSearch<TDocument>
12+
{
13+
[JsonIgnore]
14+
public IReadOnlyCollection<Hit<TDocument>> Hits => HitsMetadata.Hits;
15+
16+
[JsonIgnore]
17+
public IReadOnlyCollection<TDocument> Documents => HitsMetadata.Hits.Select(s => s.Source).ToReadOnlyCollection();
18+
19+
[JsonIgnore]
20+
public long Total => HitsMetadata?.Total?.Value ?? -1;
21+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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;
6+
using System.Text.Json.Serialization;
7+
8+
namespace Elastic.Clients.Elasticsearch.AsyncSearch;
9+
10+
public partial class AsyncSearchStatusResponse
11+
{
12+
[JsonIgnore]
13+
public DateTimeOffset StartTime => StartTimeInMillis.DateTimeOffset;
14+
15+
[JsonIgnore]
16+
public DateTimeOffset ExpirationTime => ExpirationTimeInMillis.DateTimeOffset;
17+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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;
6+
using Elastic.Clients.Elasticsearch.QueryDsl;
7+
8+
namespace Elastic.Clients.Elasticsearch.AsyncSearch;
9+
10+
public sealed partial class AsyncSearchSubmitRequestDescriptor
11+
{
12+
public AsyncSearchSubmitRequestDescriptor MatchAll(Action<MatchAllQueryDescriptor>? selector = null) => selector is null ? Query(q => q.MatchAll()) : Query(q => q.MatchAll(selector));
13+
}

src/Elastic.Clients.Elasticsearch/Api/GetAsyncSearchResponse.cs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,10 @@
33
// See the LICENSE file in the project root for more information.
44

55
using System;
6-
using System.Collections.Generic;
7-
using System.Linq;
86
using System.Text.Json.Serialization;
9-
using Elastic.Clients.Elasticsearch.QueryDsl;
107

118
namespace Elastic.Clients.Elasticsearch.AsyncSearch;
129

13-
public partial class AsyncSearch<TDocument>
14-
{
15-
[JsonIgnore]
16-
public IReadOnlyCollection<Hit<TDocument>> Hits => HitsMetadata.Hits;
17-
18-
[JsonIgnore]
19-
public IReadOnlyCollection<TDocument> Documents => HitsMetadata.Hits.Select(s => s.Source).ToReadOnlyCollection();
20-
21-
[JsonIgnore]
22-
public long Total => HitsMetadata?.Total?.Value ?? -1;
23-
}
24-
2510
public partial class GetAsyncSearchResponse<TDocument>
2611
{
2712
[JsonIgnore]
@@ -30,17 +15,3 @@ public partial class GetAsyncSearchResponse<TDocument>
3015
[JsonIgnore]
3116
public DateTimeOffset ExpirationTime => ExpirationTimeInMillis.DateTimeOffset;
3217
}
33-
34-
public partial class AsyncSearchStatusResponse
35-
{
36-
[JsonIgnore]
37-
public DateTimeOffset StartTime => StartTimeInMillis.DateTimeOffset;
38-
39-
[JsonIgnore]
40-
public DateTimeOffset ExpirationTime => ExpirationTimeInMillis.DateTimeOffset;
41-
}
42-
43-
public sealed partial class AsyncSearchSubmitRequestDescriptor
44-
{
45-
public AsyncSearchSubmitRequestDescriptor MatchAll(Action<MatchAllQueryDescriptor>? selector = null) => selector is null ? Query(q => q.MatchAll()) : Query(q => q.MatchAll(selector));
46-
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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.Collections.Generic;
6+
using System.Linq;
7+
using System.Text.Json.Serialization;
8+
9+
namespace Elastic.Clients.Elasticsearch;
10+
11+
public partial class ScrollResponse<TDocument>
12+
{
13+
[JsonIgnore]
14+
public IReadOnlyCollection<Hit<TDocument>> Hits => HitsMetadata.Hits;
15+
16+
[JsonIgnore]
17+
public IReadOnlyCollection<TDocument> Documents => HitsMetadata.Hits.Select(s => s.Source).ToReadOnlyCollection();
18+
19+
[JsonIgnore]
20+
public long Total => HitsMetadata?.Total?.Value ?? -1;
21+
}

src/Elastic.Clients.Elasticsearch/_Generated/Api/ApiUrlsLookup.g.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ internal static class ApiUrlsLookups
4141
internal static ApiUrls CrossClusterReplicationResumeFollow = new ApiUrls(new[] { "/{index}/_ccr/resume_follow" });
4242
internal static ApiUrls CrossClusterReplicationStats = new ApiUrls(new[] { "/_ccr/stats" });
4343
internal static ApiUrls CrossClusterReplicationUnfollow = new ApiUrls(new[] { "/{index}/_ccr/unfollow" });
44+
internal static ApiUrls NoNamespaceClearScroll = new ApiUrls(new[] { "/_search/scroll" });
4445
internal static ApiUrls NoNamespaceClosePointInTime = new ApiUrls(new[] { "/_pit" });
4546
internal static ApiUrls ClusterAllocationExplain = new ApiUrls(new[] { "/_cluster/allocation/explain" });
4647
internal static ApiUrls ClusterDeleteComponentTemplate = new ApiUrls(new[] { "/_component_template/{name}" });
@@ -231,6 +232,7 @@ internal static class ApiUrlsLookups
231232
internal static ApiUrls NoNamespaceReindexRethrottle = new ApiUrls(new[] { "/_reindex/{task_id}/_rethrottle" });
232233
internal static ApiUrls NoNamespaceGetScriptContext = new ApiUrls(new[] { "/_script_context" });
233234
internal static ApiUrls NoNamespaceGetScriptLanguages = new ApiUrls(new[] { "/_script_language" });
235+
internal static ApiUrls NoNamespaceScroll = new ApiUrls(new[] { "/_search/scroll" });
234236
internal static ApiUrls SearchableSnapshotsCacheStats = new ApiUrls(new[] { "/_searchable_snapshots/cache/stats", "/_searchable_snapshots/{node_id}/cache/stats" });
235237
internal static ApiUrls SearchableSnapshotsClearCache = new ApiUrls(new[] { "/_searchable_snapshots/cache/clear", "/{index}/_searchable_snapshots/cache/clear" });
236238
internal static ApiUrls SearchableSnapshotsMount = new ApiUrls(new[] { "/_snapshot/{repository}/{snapshot}/_mount" });
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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+
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
6+
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
7+
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗
8+
// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝
9+
// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗
10+
// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝
11+
// ------------------------------------------------
12+
//
13+
// This file is automatically generated.
14+
// Please do not edit these files manually.
15+
//
16+
// ------------------------------------------------
17+
18+
using Elastic.Transport;
19+
using System;
20+
using System.Collections.Generic;
21+
using System.Linq.Expressions;
22+
using System.Text.Json;
23+
using System.Text.Json.Serialization;
24+
25+
#nullable restore
26+
namespace Elastic.Clients.Elasticsearch
27+
{
28+
public class ClearScrollRequestParameters : RequestParameters<ClearScrollRequestParameters>
29+
{
30+
}
31+
32+
public partial class ClearScrollRequest : PlainRequestBase<ClearScrollRequestParameters>
33+
{
34+
internal override ApiUrls ApiUrls => ApiUrlsLookups.NoNamespaceClearScroll;
35+
protected override HttpMethod HttpMethod => HttpMethod.DELETE;
36+
protected override bool SupportsBody => false;
37+
}
38+
39+
public sealed partial class ClearScrollRequestDescriptor : RequestDescriptorBase<ClearScrollRequestDescriptor, ClearScrollRequestParameters>
40+
{
41+
internal ClearScrollRequestDescriptor(Action<ClearScrollRequestDescriptor> configure) => configure.Invoke(this);
42+
public ClearScrollRequestDescriptor()
43+
{
44+
}
45+
46+
internal override ApiUrls ApiUrls => ApiUrlsLookups.NoNamespaceClearScroll;
47+
protected override HttpMethod HttpMethod => HttpMethod.DELETE;
48+
protected override bool SupportsBody => false;
49+
protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
50+
{
51+
}
52+
}
53+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
6+
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
7+
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗
8+
// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝
9+
// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗
10+
// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝
11+
// ------------------------------------------------
12+
//
13+
// This file is automatically generated.
14+
// Please do not edit these files manually.
15+
//
16+
// ------------------------------------------------
17+
18+
using Elastic.Transport.Products.Elasticsearch;
19+
using System.Collections.Generic;
20+
using System.Text.Json.Serialization;
21+
22+
#nullable restore
23+
namespace Elastic.Clients.Elasticsearch
24+
{
25+
public partial class ClearScrollResponse : ElasticsearchResponseBase
26+
{
27+
[JsonInclude]
28+
[JsonPropertyName("num_freed")]
29+
public int NumFreed { get; init; }
30+
31+
[JsonInclude]
32+
[JsonPropertyName("succeeded")]
33+
public bool Succeeded { get; init; }
34+
}
35+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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+
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
6+
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
7+
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗
8+
// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝
9+
// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗
10+
// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝
11+
// ------------------------------------------------
12+
//
13+
// This file is automatically generated.
14+
// Please do not edit these files manually.
15+
//
16+
// ------------------------------------------------
17+
18+
using Elastic.Transport;
19+
using System;
20+
using System.Collections.Generic;
21+
using System.Linq.Expressions;
22+
using System.Text.Json;
23+
using System.Text.Json.Serialization;
24+
25+
#nullable restore
26+
namespace Elastic.Clients.Elasticsearch
27+
{
28+
public class ScrollRequestParameters : RequestParameters<ScrollRequestParameters>
29+
{
30+
[JsonIgnore]
31+
public bool? RestTotalHitsAsInt { get => Q<bool?>("rest_total_hits_as_int"); set => Q("rest_total_hits_as_int", value); }
32+
}
33+
34+
public partial class ScrollRequest : PlainRequestBase<ScrollRequestParameters>
35+
{
36+
internal override ApiUrls ApiUrls => ApiUrlsLookups.NoNamespaceScroll;
37+
protected override HttpMethod HttpMethod => HttpMethod.POST;
38+
protected override bool SupportsBody => true;
39+
[JsonIgnore]
40+
public bool? RestTotalHitsAsInt { get => Q<bool?>("rest_total_hits_as_int"); set => Q("rest_total_hits_as_int", value); }
41+
42+
[JsonInclude]
43+
[JsonPropertyName("scroll")]
44+
public Elastic.Clients.Elasticsearch.Time? Scroll { get; set; }
45+
}
46+
47+
public sealed partial class ScrollRequestDescriptor : RequestDescriptorBase<ScrollRequestDescriptor, ScrollRequestParameters>
48+
{
49+
internal ScrollRequestDescriptor(Action<ScrollRequestDescriptor> configure) => configure.Invoke(this);
50+
public ScrollRequestDescriptor()
51+
{
52+
}
53+
54+
internal override ApiUrls ApiUrls => ApiUrlsLookups.NoNamespaceScroll;
55+
protected override HttpMethod HttpMethod => HttpMethod.POST;
56+
protected override bool SupportsBody => true;
57+
public ScrollRequestDescriptor RestTotalHitsAsInt(bool? restTotalHitsAsInt = true) => Qs("rest_total_hits_as_int", restTotalHitsAsInt);
58+
private Elastic.Clients.Elasticsearch.Time? ScrollValue { get; set; }
59+
60+
public ScrollRequestDescriptor Scroll(Elastic.Clients.Elasticsearch.Time? scroll)
61+
{
62+
ScrollValue = scroll;
63+
return Self;
64+
}
65+
66+
protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
67+
{
68+
writer.WriteStartObject();
69+
if (ScrollValue is not null)
70+
{
71+
writer.WritePropertyName("scroll");
72+
JsonSerializer.Serialize(writer, ScrollValue, options);
73+
}
74+
75+
writer.WriteEndObject();
76+
}
77+
}
78+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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+
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
6+
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
7+
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗
8+
// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝
9+
// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗
10+
// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝
11+
// ------------------------------------------------
12+
//
13+
// This file is automatically generated.
14+
// Please do not edit these files manually.
15+
//
16+
// ------------------------------------------------
17+
18+
using Elastic.Transport.Products.Elasticsearch;
19+
using System.Collections.Generic;
20+
using System.Text.Json.Serialization;
21+
22+
#nullable restore
23+
namespace Elastic.Clients.Elasticsearch
24+
{
25+
public partial class ScrollResponse<TDocument> : ElasticsearchResponseBase
26+
{
27+
[JsonInclude]
28+
[JsonPropertyName("aggregations")]
29+
public Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary? Aggregations { get; init; }
30+
31+
[JsonInclude]
32+
[JsonPropertyName("_clusters")]
33+
public Elastic.Clients.Elasticsearch.ClusterStatistics? Clusters { get; init; }
34+
35+
[JsonInclude]
36+
[JsonPropertyName("fields")]
37+
public Dictionary<string, object>? Fields { get; init; }
38+
39+
[JsonInclude]
40+
[JsonPropertyName("hits")]
41+
public Elastic.Clients.Elasticsearch.HitsMetadata<TDocument> HitsMetadata { get; init; }
42+
43+
[JsonInclude]
44+
[JsonPropertyName("max_score")]
45+
public double? MaxScore { get; init; }
46+
47+
[JsonInclude]
48+
[JsonPropertyName("num_reduce_phases")]
49+
public long? NumReducePhases { get; init; }
50+
51+
[JsonInclude]
52+
[JsonPropertyName("pit_id")]
53+
public string? PitId { get; init; }
54+
55+
[JsonInclude]
56+
[JsonPropertyName("profile")]
57+
public Elastic.Clients.Elasticsearch.Profile? Profile { get; init; }
58+
59+
[JsonInclude]
60+
[JsonPropertyName("_scroll_id")]
61+
public string? ScrollId { get; init; }
62+
63+
[JsonInclude]
64+
[JsonPropertyName("_shards")]
65+
public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; }
66+
67+
[JsonInclude]
68+
[JsonPropertyName("terminated_early")]
69+
public bool? TerminatedEarly { get; init; }
70+
71+
[JsonInclude]
72+
[JsonPropertyName("timed_out")]
73+
public bool TimedOut { get; init; }
74+
75+
[JsonInclude]
76+
[JsonPropertyName("took")]
77+
public long Took { get; init; }
78+
}
79+
}

0 commit comments

Comments
 (0)