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,
with bucket intervals based on the UTC time zone.
|
Aggregate |
timeSeries(java.lang.String fieldName,
TimeInterval interval,
java.lang.String timeZone)
Adds a time-series aggregate to the query for the given field name,
with bucket intervals based on the designated time zone.
|
Aggregate |
topValues(java.lang.String fieldName)
Adds a top-values aggregate to the query for the given field name.
|
Aggregate |
topValues(java.lang.String fieldName,
int offset,
int limit)
Adds a top-values aggregate to the query for the given field name, with offset
and limit parameters to allow paging through the aggregate results.
|
public static Aggregate builder()
public java.lang.String build()
public Aggregate topValues(java.lang.String fieldName)
client.searchCollection("someCollection")
.aggregate(Aggregate.builder()
.topValues("value.tags")
.build()
)
.get(String.class, "*")
.get()
fieldName - The fully-qualified name of the field to aggregate uponpublic Aggregate topValues(java.lang.String fieldName, int offset, int limit)
client.searchCollection("someCollection")
.aggregate(Aggregate.builder()
.topValues("value.tags", 20, 10)
.build()
)
.get(String.class, "*")
.get()
fieldName - The fully-qualified name of the field to aggregate uponoffset - The offset of the first top-values result entry to includelimit - The maximum number of top-values result entries to retrievepublic 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 uponpublic Aggregate timeSeries(java.lang.String fieldName, TimeInterval interval, java.lang.String timeZone)
client.searchCollection("someCollection")
.aggregate(Aggregate.builder()
.timeSeries("value.date_of_birth", TimeInterval.MONTH, "-0500")
.build()
)
.get(String.class, "*")
.get()
fieldName - The fully-qualified name of the field to aggregate uponinterval - The time interval to bucket upontimeZone - The time zone to use when computing interval bucket boundaries