`
datastore.aggregate()
.match()
.project()
.unwind()
.group(group(id("my_id")).field("totalCount", sum("1")).field("average", avg(field("field2"))))
.execute(result::class.java)
.toList()
`
In CLI it works something like $sum: 1 in group to do a count(*) but how to do this in kotlin/java code??
I just want to count all occurences after group by. Basically similar to select count(*) from table group by name;
UPDATE: Got through the docs after investing hours. We can use sum(literal(1))
to do the same in aggregation query in kotlin.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.