committed by
Mark Paluch
parent
72d82d3083
commit
dd446472bc
@@ -55,6 +55,14 @@ public class SelectionOperators {
|
|||||||
return new Bottom(Collections.emptyMap());
|
return new Bottom(Collections.emptyMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param numberOfResults Limits the number of returned elements to the given value.
|
||||||
|
* @return new instance of {@link Bottom}.
|
||||||
|
*/
|
||||||
|
public static Bottom bottom(int numberOfResults) {
|
||||||
|
return bottom().limit(numberOfResults);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Limits the number of returned elements to the given value.
|
* Limits the number of returned elements to the given value.
|
||||||
*
|
*
|
||||||
@@ -239,14 +247,14 @@ public class SelectionOperators {
|
|||||||
* @return new instance of {@link First}.
|
* @return new instance of {@link First}.
|
||||||
*/
|
*/
|
||||||
public static First first() {
|
public static First first() {
|
||||||
return new First(Collections.emptyMap()).limit(1);
|
return new First(Collections.emptyMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return new instance of {@link First}.
|
* @return new instance of {@link First}.
|
||||||
*/
|
*/
|
||||||
public static First first(int numberOfResults) {
|
public static First first(int numberOfResults) {
|
||||||
return new First(Collections.emptyMap()).limit(numberOfResults);
|
return first().limit(numberOfResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -333,14 +341,14 @@ public class SelectionOperators {
|
|||||||
* @return new instance of {@link Last}.
|
* @return new instance of {@link Last}.
|
||||||
*/
|
*/
|
||||||
public static Last last() {
|
public static Last last() {
|
||||||
return new Last(Collections.emptyMap()).limit(1);
|
return new Last(Collections.emptyMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return new instance of {@link Last}.
|
* @return new instance of {@link Last}.
|
||||||
*/
|
*/
|
||||||
public static Last last(int numberOfResults) {
|
public static Last last(int numberOfResults) {
|
||||||
return new Last(Collections.emptyMap()).limit(numberOfResults);
|
return last().limit(numberOfResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -74,8 +74,8 @@ class SelectionOperatorUnitTests {
|
|||||||
@Test // GH-4139
|
@Test // GH-4139
|
||||||
void bottomNRenderedCorrectly() {
|
void bottomNRenderedCorrectly() {
|
||||||
|
|
||||||
Document document = SelectionOperators.Bottom.bottom().output(Fields.fields("playerId", "score"))
|
Document document = SelectionOperators.Bottom.bottom(3).output(Fields.fields("playerId", "score"))
|
||||||
.sortBy(Sort.by(Direction.DESC, "score")).limit(3).toDocument(Aggregation.DEFAULT_CONTEXT);
|
.sortBy(Sort.by(Direction.DESC, "score")).toDocument(Aggregation.DEFAULT_CONTEXT);
|
||||||
|
|
||||||
assertThat(document).isEqualTo(Document.parse("""
|
assertThat(document).isEqualTo(Document.parse("""
|
||||||
{
|
{
|
||||||
@@ -114,8 +114,8 @@ class SelectionOperatorUnitTests {
|
|||||||
@Test // GH-4139
|
@Test // GH-4139
|
||||||
void topNRenderedCorrectly() {
|
void topNRenderedCorrectly() {
|
||||||
|
|
||||||
Document document = SelectionOperators.Top.top().output(Fields.fields("playerId", "score"))
|
Document document = SelectionOperators.Top.top(3).output(Fields.fields("playerId", "score"))
|
||||||
.sortBy(Sort.by(Direction.DESC, "score")).limit(3).toDocument(Aggregation.DEFAULT_CONTEXT);
|
.sortBy(Sort.by(Direction.DESC, "score")).toDocument(Aggregation.DEFAULT_CONTEXT);
|
||||||
|
|
||||||
assertThat(document).isEqualTo(Document.parse("""
|
assertThat(document).isEqualTo(Document.parse("""
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user