Skip to content

Avoid simplifying scroll IDs on responses #6480

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ private IndexName(string index, Type type, string cluster = null)
Cluster = cluster;
}

public string Cluster { get; }
public string Name { get; }
public Type Type { get; }
internal string Cluster { get; }
internal string Name { get; }
internal Type Type { get; }

internal string DebugDisplay => Type == null ? Name : $"{nameof(IndexName)} for typeof: {Type?.Name}";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class Username : IEquatable<Username>, IUrlParameter
{
public Username(string name) => Value = name?.Trim();

internal string Value { get; }
public string Value { get; }

private string DebugDisplay => Value;

Expand All @@ -25,7 +25,7 @@ public class Username : IEquatable<Username>, IUrlParameter

string IUrlParameter.GetString(ITransportConfiguration? settings) => Value;

public override string ToString() => DebugDisplay;
public override string ToString() => Value;

public static implicit operator Username(string name) => name.IsNullOrEmpty() ? null : new Username(name);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public sealed partial class ScrollResponse<TDocument> : ElasticsearchResponseBas

[JsonInclude]
[JsonPropertyName("_scroll_id")]
public string? ScrollId { get; init; }
public Elastic.Clients.Elasticsearch.ScrollId? ScrollId { get; init; }

[JsonInclude]
[JsonPropertyName("_shards")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public sealed partial class SearchResponse<TDocument> : ElasticsearchResponseBas

[JsonInclude]
[JsonPropertyName("_scroll_id")]
public string? ScrollId { get; init; }
public Elastic.Clients.Elasticsearch.ScrollId? ScrollId { get; init; }

[JsonInclude]
[JsonPropertyName("_shards")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public partial class AsyncSearch<TDocument>

[JsonInclude]
[JsonPropertyName("_scroll_id")]
public string? ScrollId { get; init; }
public Elastic.Clients.Elasticsearch.ScrollId? ScrollId { get; init; }

[JsonInclude]
[JsonPropertyName("_shards")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ public enum ClusterPrivilege
Monitor,
[EnumMember(Value = "manage_watcher")]
ManageWatcher,
[EnumMember(Value = "manage_user_profile")]
ManageUserProfile,
[EnumMember(Value = "manage_transform")]
ManageTransform,
[EnumMember(Value = "manage_token")]
Expand Down Expand Up @@ -232,6 +234,8 @@ public override ClusterPrivilege Read(ref Utf8JsonReader reader, Type typeToConv
return ClusterPrivilege.Monitor;
case "manage_watcher":
return ClusterPrivilege.ManageWatcher;
case "manage_user_profile":
return ClusterPrivilege.ManageUserProfile;
case "manage_transform":
return ClusterPrivilege.ManageTransform;
case "manage_token":
Expand Down Expand Up @@ -327,6 +331,9 @@ public override void Write(Utf8JsonWriter writer, ClusterPrivilege value, JsonSe
case ClusterPrivilege.ManageWatcher:
writer.WriteStringValue("manage_watcher");
return;
case ClusterPrivilege.ManageUserProfile:
writer.WriteStringValue("manage_user_profile");
return;
case ClusterPrivilege.ManageTransform:
writer.WriteStringValue("manage_transform");
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,5 @@ public partial class MigrationFeature
[JsonInclude]
[JsonPropertyName("feature_name")]
public string FeatureName { get; init; }

[JsonInclude]
[JsonPropertyName("indices")]
public IReadOnlyCollection<Elastic.Clients.Elasticsearch.Migration.MigrationFeatureIndexInfo> Indices { get; init; }

[JsonInclude]
[JsonPropertyName("migration_status")]
public Elastic.Clients.Elasticsearch.Migration.MigrationStatus MigrationStatus { get; init; }

[JsonInclude]
[JsonPropertyName("minimum_index_version")]
public string MinimumIndexVersion { get; init; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public partial class ResponseBody<TDocument>

[JsonInclude]
[JsonPropertyName("_scroll_id")]
public string? ScrollId { get; init; }
public Elastic.Clients.Elasticsearch.ScrollId? ScrollId { get; init; }

[JsonInclude]
[JsonPropertyName("_shards")]
Expand Down
6 changes: 4 additions & 2 deletions tests/Tests/AsyncSearch/AsyncSearchApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ public AsyncSearchApiTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(
u.Calls<GetAsyncSearchRequestDescriptor<Project>, GetAsyncSearchRequest, GetAsyncSearchResponse<Project>>(
v => new GetAsyncSearchRequest(v),
(v, d) => d,
(v, c, f) => c.AsyncSearch.Get<Project>(v, f),
(v, c, f) => c.AsyncSearch.GetAsync<Project>(v, f),
(v, c, f) => c.AsyncSearch.Get(v, f),
(v, c, f) => c.AsyncSearch.GetAsync(v, f),
(v, c, r) => c.AsyncSearch.Get<Project>(r),
(v, c, r) => c.AsyncSearch.GetAsync<Project>(r),
uniqueValueSelector: values => values.ExtendedValue<string>("id")
Expand All @@ -120,6 +120,8 @@ public AsyncSearchApiTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(
public async Task AsyncSearchSubmitResponse() => await Assert<AsyncSearchSubmitResponse<Project>>(SubmitStep, r =>
{
r.ShouldBeValid();
r.Id.Should().NotBeNullOrEmpty();
// TODO - MORE ASSERTIONS
r.Response.Should().NotBeNull();
r.Response.Took.Should().BeGreaterOrEqualTo(0);
});
Expand Down
5 changes: 3 additions & 2 deletions tests/Tests/Common/Infer/Indices/IndicesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,12 @@ public async Task Serializes_All_Correctly()
}

[U]
public async void Deserializes_All_Correctly()
public void Deserializes_All_Correctly()
{
const string json = @"{""indices"":""_all""}";
var obj = DeserializeJsonString<TestThing>(json);
await Verifier.Verify(obj);
obj.Indices.Should().HaveCount(1);
obj.Indices.First().Name.Should().Be("_all");
}

[U]
Expand Down
5 changes: 4 additions & 1 deletion tests/Tests/Serialization/Documents/MGetSerialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public async Task DeserializesError()
var error = search.Docs.First().Item2;
error.Should().NotBeNull();

await Verifier.Verify(error);
error.Id.Should().Be("1001");
error.Index.Should().Be("devs");

await Verifier.Verify(error.Error);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
{
Id: 1001,
Index: devs,
Error: {
Reason: routing is required for [devs]/[1001],
RootCause: [
{
Reason: routing is required for [devs]/[1001],
Type: routing_missing_exception
}
],
Type: routing_missing_exception
}
Reason: routing is required for [devs]/[1001],
RootCause: [
{
Reason: routing is required for [devs]/[1001],
Type: routing_missing_exception
}
],
Type: routing_missing_exception
}