mirror of
https://github.com/d0zingcat/opensearch-orm.git
synced 2026-05-14 07:26:50 +00:00
docs: add aggregations example
This commit is contained in:
12
README.md
12
README.md
@@ -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}
|
||||
```
|
||||
Reference in New Issue
Block a user