Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions awswrangler/opensearch/_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ def index_documents(
initial_backoff: int | None = None,
max_backoff: int | None = None,
use_threads: bool | int = False,
modify_refresh_interval: bool = True,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but perhaps enable_refresh_interval is a better name?

Copy link
Contributor Author

@AvihaiSam AvihaiSam Oct 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure... whatever works for you...
pushed the changes...

**kwargs: Any,
) -> dict[str, Any]:
"""
Expand Down Expand Up @@ -559,6 +560,8 @@ def index_documents(
True to enable concurrent requests, False to disable multiple threads.
If enabled os.cpu_count() will be used as the max number of threads.
If integer is provided, specified number is used.
modify_refresh_interval
True (default) to enable ``refresh_interval`` modification to ``-1`` (disabled) while indexing documents
**kwargs
KEYWORD arguments forwarded to bulk operation
elasticsearch >= 7.10.2 / opensearch: \
Expand Down Expand Up @@ -614,7 +617,7 @@ def index_documents(
widgets=widgets, max_value=total_documents, prefix="Indexing: "
).start()
for i, bulk_chunk_documents in enumerate(actions):
if i == 1: # second bulk iteration, in case the index didn't exist before
if i == 1 and modify_refresh_interval: # second bulk iteration, in case the index didn't exist before
refresh_interval = _get_refresh_interval(client, index)
_disable_refresh_interval(client, index)
_logger.debug("running bulk index of %s documents", len(bulk_chunk_documents))
Expand Down Expand Up @@ -655,6 +658,7 @@ def index_documents(
raise e

finally:
_set_refresh_interval(client, index, refresh_interval)
if modify_refresh_interval:
_set_refresh_interval(client, index, refresh_interval)

return {"success": success, "errors": errors}