From 9a54d8f3e04e67fe1c813524fbf144a9e09dd727 Mon Sep 17 00:00:00 2001 From: yim7 Date: Sat, 17 Jun 2023 15:12:59 +0800 Subject: [PATCH] feat: scroll --- README.md | 27 +++++++++++++++++++++++++++ pyproject.toml | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d032021..14cfcf3 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,14 @@ with SearchSession() as session: .filter(Contains('method', ['GET', 'POST'])) .fetch() ) + + # single value + result = ( + session.select(UserLog) + .filter(method__contains='GET') + .fetch() + ) + print(result) ``` ## exclude @@ -105,3 +113,22 @@ with SearchSession() as session: print(result) # result -> {'path': 1, 'path2': 2} ``` + +## scroll +``` +with SearchSession() as session: + start = datetime(2023, 4, 15, 19, tzinfo=TZ) + end = datetime(2023, 4, 15, 21, tzinfo=TZ) + + scroll = ( + session.select(Model) + .filter( + created__gte=start, + created__lte=end, + ) + .limit(10000) + .scroll('1m') + ) + for records in scroll: + print('-------scroll', len(records)) +``` \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 28d5c02..19757e2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "opensearch-orm" -version = "0.1.6" +version = "0.1.7" description = "" authors = ["yim7 "] readme = "README.md"