feat: scroll

This commit is contained in:
yim7
2023-06-17 15:12:59 +08:00
parent b304811fee
commit 9a54d8f3e0
2 changed files with 28 additions and 1 deletions

View File

@@ -63,6 +63,14 @@ with SearchSession() as session:
.filter(Contains('method', ['GET', 'POST'])) .filter(Contains('method', ['GET', 'POST']))
.fetch() .fetch()
) )
# single value
result = (
session.select(UserLog)
.filter(method__contains='GET')
.fetch()
)
print(result)
``` ```
## exclude ## exclude
@@ -105,3 +113,22 @@ with SearchSession() as session:
print(result) print(result)
# result -> {'path': 1, 'path2': 2} # 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))
```

View File

@@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "opensearch-orm" name = "opensearch-orm"
version = "0.1.6" version = "0.1.7"
description = "" description = ""
authors = ["yim7 <yimchiu7@gmail.com>"] authors = ["yim7 <yimchiu7@gmail.com>"]
readme = "README.md" readme = "README.md"