Skip to content

Commit

Permalink
Add generic scroll/size parameters to scan calls
Browse files Browse the repository at this point in the history
  • Loading branch information
stchris committed Jun 21, 2023
1 parent 3eb7214 commit 947165f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
8 changes: 4 additions & 4 deletions aleph.env.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ ALEPH_OAUTH_SECRET=
# To use an external ElasticSearch service:
# ALEPH_ELASTICSEARCH_URI=

# 'scroll' parameter used on ES scan() calls for xref operations
# 'scroll' parameter used on ES scan() calls
# (how long a consistent view of the index should be maintained for scrolled search)
# ALEPH_XREF_SCROLL = 5m
# ALEPH_ELASTICSEARCH_SCROLL = 5m

# 'size' parameter used on ES scan() calls for xref operations
# 'size' parameter used on ES scan() calls
# size (per shard) of the batch send for each iteration of a scan
# ALEPH_XREF_SCROLL_SIZE = 1000
# ALEPH_ELASTICSEARCH_SCROLL_SIZE = 1000

# To use an external Postgres service:
# ALEPH_DATABASE_URI=postgresql://<username>:<password>@<host>/<database>
Expand Down
2 changes: 2 additions & 0 deletions aleph/index/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ def iter_entities(
timeout=MAX_TIMEOUT,
request_timeout=MAX_REQUEST_TIMEOUT,
preserve_order=preserve_order,
scroll=SETTINGS.ELASTICSEARCH_SCROLL,
size=SETTINGS.ELASTICSEARCH_SCROLL_SIZE,
):
entity = unpack_result(res)
if entity is not None:
Expand Down
4 changes: 2 additions & 2 deletions aleph/index/xref.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ def iter_matches(collection, authz):
es,
index=xref_index(),
query=query,
scroll=SETTINGS.XREF_SCROLL,
size=SETTINGS.XREF_SCROLL_SIZE,
scroll=SETTINGS.ELASTICSEARCH_SCROLL,
size=SETTINGS.ELASTICSEARCH_SCROLL_SIZE,
):
yield unpack_result(res)

Expand Down
4 changes: 2 additions & 2 deletions aleph/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ def __init__(self) -> None:
"ALEPH_ELASTICSEARCH_URI", "http://localhost:9200"
)
self.ELASTICSEARCH_TIMEOUT = env.to_int("ELASTICSEARCH_TIMEOUT", 60)
self.XREF_SCROLL = env.get("ALEPH_XREF_SCROLL", "5m")
self.XREF_SCROLL_SIZE = env.get("ALEPH_XREF_SCROLL_SIZE", "1000")
self.ELASTICSEARCH_SCROLL = env.get("ALEPH_ELASTICSEARCH_SCROLL", "5m")
self.ELASTICSEARCH_SCROLL_SIZE = env.get("ALEPH_ELASTICSEARCH_SCROLL_SIZE", "1000")

# Number of replicas to maintain. '2' means 3 overall copies.
self.INDEX_REPLICAS = env.to_int("ALEPH_INDEX_REPLICAS", 0)
Expand Down

0 comments on commit 947165f

Please sign in to comment.