Skip to content

Commit

Permalink
separate option for SORTBY MAX
Browse files Browse the repository at this point in the history
  • Loading branch information
sazzad16 committed Jun 1, 2023
1 parent d4193f7 commit 1bdf7ea
Showing 1 changed file with 27 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,6 @@ public AggregationBuilder sortBy(SortedField... fields) {
args.add(field.getField());
args.add(field.getOrder());
}

return this;
}

public AggregationBuilder sortBy(int max, SortedField... fields) {
sortBy(fields);
if (max > 0) {
args.add(SearchKeyword.MAX);
args.add(max);
}
return this;
}

Expand All @@ -90,6 +80,33 @@ public AggregationBuilder sortByDesc(String field) {
return sortBy(SortedField.desc(field));
}

/**
* {@link AggregationBuilder#sortBy(redis.clients.jedis.search.aggr.SortedField...)}
* (or {@link AggregationBuilder#sortByAsc(java.lang.String)}
* or {@link AggregationBuilder#sortByDesc(java.lang.String)})
* MUST BE called JUST BEFORE this.
* @param max limit
* @return this
*/
public AggregationBuilder sortByMax(int max) {
args.add(SearchKeyword.MAX);
args.add(max);
return this;
}

/**
* Shortcut to {@link AggregationBuilder#sortBy(redis.clients.jedis.search.aggr.SortedField...)}
* and {@link AggregationBuilder#sortByMax(int)}.
* @param max limit
* @param fields sorted fields
* @return this
*/
public AggregationBuilder sortBy(int max, SortedField... fields) {
sortBy(fields);
sortByMax(max);
return this;
}

public AggregationBuilder apply(String projection, String alias) {
args.add(SearchKeyword.APPLY);
args.add(projection);
Expand Down

0 comments on commit 1bdf7ea

Please sign in to comment.