|
|
|
|
@ -18,6 +18,8 @@ package org.springframework.data.mongodb.core.aggregation;
@@ -18,6 +18,8 @@ package org.springframework.data.mongodb.core.aggregation;
|
|
|
|
|
import org.bson.Document; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Gateway to {@literal document expressions} such as {@literal $rank, $documentNumber, etc.} |
|
|
|
|
* |
|
|
|
|
* @author Christoph Strobl |
|
|
|
|
* @since 3.3 |
|
|
|
|
*/ |
|
|
|
|
@ -43,6 +45,16 @@ public class DocumentOperators {
@@ -43,6 +45,16 @@ public class DocumentOperators {
|
|
|
|
|
return new DenseRank(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Obtain the current document position. |
|
|
|
|
* |
|
|
|
|
* @return new instance of {@link DocumentNumber}. |
|
|
|
|
* @since 3.3 |
|
|
|
|
*/ |
|
|
|
|
public static DocumentNumber documentNumber() { |
|
|
|
|
return new DocumentNumber(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* {@link Rank} resolves the current document position (the rank) relative to other documents. If multiple documents |
|
|
|
|
* occupy the same rank, {@literal $rank} places the document with the subsequent value at a rank with a gap. |
|
|
|
|
@ -73,4 +85,18 @@ public class DocumentOperators {
@@ -73,4 +85,18 @@ public class DocumentOperators {
|
|
|
|
|
return new Document("$denseRank", new Document()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* {@link DocumentNumber} resolves the current document position. |
|
|
|
|
* |
|
|
|
|
* @author Christoph Strobl |
|
|
|
|
* @since 3.3 |
|
|
|
|
*/ |
|
|
|
|
public static class DocumentNumber implements AggregationExpression { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Document toDocument(AggregationOperationContext context) { |
|
|
|
|
return new Document("$documentNumber", new Document()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|