docs: add aggregations example

This commit is contained in:
yim7
2022-09-22 13:29:17 +08:00
parent 8a9c3974fc
commit ba65247790

View File

@@ -89,4 +89,16 @@ with SearchSession() as session:
.fetch()
)
print(result)
```
## aggregations
group by path and count unique remote_ip
``` python
with SearchSession() as session:
result = (
session.select(UserLog)
.aggregate(Terms('path').nested(Cardinality('remote_ip')))
)
print(result)
# result -> {'path': 1, 'path2': 2}
```