Skip to content

Commit

Permalink
Deprecate sort on ReindexOnServer (#4357)
Browse files Browse the repository at this point in the history
Relates: #4341

Deprecate sorting in reindex elastic/elasticsearch#49458 (issue: elastic/elasticsearch#47567)

Closes #4356
  • Loading branch information
russcam authored Feb 9, 2020
1 parent 0576da2 commit 20a2133
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Nest/Document/Multiple/ReindexOnServer/ReindexSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public interface IReindexSource
/// in conjunction with <see cref="Size" />
/// </summary>
[DataMember(Name ="sort")]
[Obsolete("Deprecated in 7.6.0. Instead consider using query filtering to find the desired subset of data.")]
IList<ISort> Sort { get; set; }

/// <summary>
Expand Down Expand Up @@ -78,6 +79,7 @@ public class ReindexSource : IReindexSource
public ISlicedScroll Slice { get; set; }

/// <inheritdoc />
[Obsolete("Deprecated in 7.6.0. Instead consider using query filtering to find the desired subset of data.")]
public IList<ISort> Sort { get; set; }

/// <inheritdoc />
Expand All @@ -100,6 +102,7 @@ public ReindexSourceDescriptor Query<T>(Func<QueryContainerDescriptor<T>, QueryC
Assign(querySelector, (a, v) => a.Query = v?.Invoke(new QueryContainerDescriptor<T>()));

/// <inheritdoc cref="IReindexSource.Sort" />
[Obsolete("Deprecated in 7.6.0. Instead consider using query filtering to find the desired subset of data.")]
public ReindexSourceDescriptor Sort<T>(Func<SortDescriptor<T>, IPromise<IList<ISort>>> selector) where T : class =>
Assign(selector, (a, v) => a.Sort = v?.Invoke(new SortDescriptor<T>())?.Value);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public ReindexOnServerApiTests(IntrusiveOperationCluster cluster, EndpointUsage

protected override int ExpectStatusCode => 200;

// Sort is deprecated
#pragma warning disable 618
protected override Func<ReindexOnServerDescriptor, IReindexOnServerRequest> Fluent => d => d
.Source(s => s
.Index(CallIsolatedValue)
Expand All @@ -56,6 +58,7 @@ public ReindexOnServerApiTests(IntrusiveOperationCluster cluster, EndpointUsage
.Query("bar")
)
)
.Sort<Test>(sort => sort
.Ascending("id")
)
Expand All @@ -69,6 +72,7 @@ public ReindexOnServerApiTests(IntrusiveOperationCluster cluster, EndpointUsage
.Script(ss => ss.Source(PainlessScript))
.Conflicts(Conflicts.Proceed)
.Refresh();
#pragma warning restore 618

protected override HttpMethod HttpMethod => HttpMethod.POST;

Expand All @@ -78,7 +82,9 @@ public ReindexOnServerApiTests(IntrusiveOperationCluster cluster, EndpointUsage
{
Index = CallIsolatedValue,
Query = new MatchQuery { Field = Field<Test>(p => p.Flag), Query = "bar" },
#pragma warning disable 618
Sort = new List<ISort> { new FieldSort { Field = "id", Order = SortOrder.Ascending } },
#pragma warning restore 618
Size = 100
},
Destination = new ReindexDestination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public ReindexOnServerSliceApiTests(IntrusiveOperationCluster cluster, EndpointU

protected override int ExpectStatusCode => 200;

#pragma warning disable 618
protected override Func<ReindexOnServerDescriptor, IReindexOnServerRequest> Fluent => d => d
.Source(s => s
.Index(CallIsolatedValue)
Expand All @@ -69,6 +70,7 @@ public ReindexOnServerSliceApiTests(IntrusiveOperationCluster cluster, EndpointU
)
.Conflicts(Conflicts.Proceed)
.Refresh();
#pragma warning restore 618

protected override HttpMethod HttpMethod => HttpMethod.POST;

Expand All @@ -78,7 +80,9 @@ public ReindexOnServerSliceApiTests(IntrusiveOperationCluster cluster, EndpointU
{
Index = CallIsolatedValue,
Query = new MatchAllQuery(),
#pragma warning disable 618
Sort = new List<ISort> { new FieldSort { Field = "id", Order = SortOrder.Ascending } },
#pragma warning restore 618
Size = 100,
Slice = new SlicedScroll { Field = "id", Id = 0, Max = 2 }
},
Expand Down

0 comments on commit 20a2133

Please sign in to comment.