mirror of
https://github.com/d0zingcat/opensearch-orm.git
synced 2026-05-13 15:09:56 +00:00
feat: scroll
This commit is contained in:
27
README.md
27
README.md
@@ -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))
|
||||||
|
```
|
||||||
@@ -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"
|
||||||
|
|||||||
Reference in New Issue
Block a user