Skip to content

Commit a5855cf

Browse files
committed
Replace confusing ToggleSort(bool) with Order(SortOrder) on sort descriptors
1 parent ce11fa7 commit a5855cf

File tree

3 files changed

+11
-19
lines changed

3 files changed

+11
-19
lines changed

Diff for: src/Nest/DSL/Search/SortFieldDescriptor.cs

+6-9
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ public virtual SortFieldDescriptor<T> Descending()
125125
return this;
126126
}
127127

128+
public virtual SortFieldDescriptor<T> Order(SortOrder order)
129+
{
130+
Self.Order = order;
131+
return this;
132+
}
133+
128134
public virtual SortFieldDescriptor<T> NestedMin()
129135
{
130136
Self.Mode = ScoreMode.Min;
@@ -169,14 +175,5 @@ public SortFieldDescriptor<T> NestedPath(Expression<Func<T, object>> objectPath)
169175
Self.NestedPath = objectPath;
170176
return this;
171177
}
172-
173-
/// <summary>
174-
/// Pass true to sort ascending false to sort descending
175-
/// </summary>
176-
public virtual SortFieldDescriptor<T> ToggleSort(bool ascending)
177-
{
178-
Self.Order = ascending ? SortOrder.Descending : SortOrder.Ascending;
179-
return this;
180-
}
181178
}
182179
}

Diff for: src/Nest/DSL/Search/SortGeoDistanceDescriptor.cs

+3-5
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,10 @@ public SortGeoDistanceDescriptor<T> Descending()
111111
Self.Order = SortOrder.Descending;
112112
return this;
113113
}
114-
/// <summary>
115-
/// Pass true to sort ascending false to sort descending
116-
/// </summary>
117-
public SortGeoDistanceDescriptor<T> ToggleSort(bool ascending)
114+
115+
public SortGeoDistanceDescriptor<T> Order(SortOrder order)
118116
{
119-
Self.Order = ascending ? SortOrder.Ascending : SortOrder.Descending;
117+
Self.Order = order;
120118
return this;
121119
}
122120

Diff for: src/Nest/DSL/Search/SortScriptDescriptor.cs

+2-5
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,9 @@ public virtual SortScriptDescriptor<T> Descending()
9393
return this;
9494
}
9595

96-
/// <summary>
97-
/// Pass true to sort ascending false to sort descending
98-
/// </summary>
99-
public SortScriptDescriptor<T> ToggleSort(bool ascending)
96+
public SortScriptDescriptor<T> Order(SortOrder order)
10097
{
101-
Self.Order = ascending ? SortOrder.Ascending : SortOrder.Descending;
98+
Self.Order = order;
10299
return this;
103100
}
104101
}

0 commit comments

Comments
 (0)