public class Aggregate
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
build()
Builds the final stringified version of your aggregate clause.
|
static Aggregate |
builder()
Creates a new empty Aggregate object, which can be used to build a collection
of aggregate clauses and form them into a syntactically correct string.
|
Aggregate |
distance(java.lang.String fieldName,
Range range,
Range... ranges)
Adds a distance aggregate to the query for the given field name.
|
Aggregate |
range(java.lang.String fieldName,
Range range,
Range... ranges)
Adds a range aggregate to the query for the given field name
|
Aggregate |
stats(java.lang.String fieldName)
Adds a statistical aggregate to the query for the given field name
|
Aggregate |
timeSeries(java.lang.String fieldName,
TimeInterval interval)
Adds a time-series aggregate to the query for the given field name
|
public static Aggregate builder()
public java.lang.String build()
public Aggregate stats(java.lang.String fieldName)
client.searchCollection("someCollection")
.aggregate(Aggregate.builder()
.stats("value.cart.items.price")
.build()
)
.get(String.class, "*")
.get()
fieldName - The fully-qualified name of the field to aggregate uponpublic Aggregate range(java.lang.String fieldName, Range range, Range... ranges)
client.searchCollection("someCollection")
.aggregate(Aggregate.builder()
.range(
"value.inventory.quantity",
Range.below(10),
Range.between(10, 100),
Range.above(100)
)
.build()
)
.get(String.class, "*")
.get()
fieldName - The fully-qualified name of the field to aggregate uponrange - The first numeric range to use as a histogram bucketranges - A varargs list of zero or more additional numeric ranges to use as histogram bucketspublic Aggregate distance(java.lang.String fieldName, Range range, Range... ranges)
client.searchCollection("someCollection")
.aggregate(Aggregate.builder()
.distance(
"value.location.geo",
Range.below(10),
Range.between(10, 100),
Range.above(100)
)
.build()
)
.get(String.class, "value.location:NEAR:{ lat: 12.34 lon: 56.78 dist: 1000km }")
.get()
fieldName - The fully-qualified name of the field to aggregate uponrange - The first numeric range to use as a histogram bucketranges - A varargs list of zero or more additional numeric ranges to use as histogram bucketspublic Aggregate timeSeries(java.lang.String fieldName, TimeInterval interval)
client.searchCollection("someCollection")
.aggregate(Aggregate.builder()
.timeSeries("value.date_of_birth", TimeInterval.MONTH)
.build()
)
.get(String.class, "*")
.get()
fieldName - The fully-qualified name of the field to aggregate uponinterval - The time interval to bucket upon