From ba6524779069acf0aadaf1aaf4a099203fdeff6b Mon Sep 17 00:00:00 2001 From: yim7 Date: Thu, 22 Sep 2022 13:29:17 +0800 Subject: [PATCH] docs: add aggregations example --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 40a9cff..7e607e0 100644 --- a/README.md +++ b/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} ``` \ No newline at end of file