Elasticsearch Python client: Global timeout configuration?

I'm working with multiple indices using the Elasticsearch Python client API and have a question about timeout configuration.

When creating the Elasticsearch client, we can specify a timeout:

client = Elasticsearch(
    [es_url],
    http_auth=(es_user, es_password),
    timeout=60,
    max_retries=config.MAX_RETRIES,
    retry_on_timeout=True
)
  1. Does this timeout apply globally to all operations performed by this client instance?

  2. For operations like search requests, scroll operations, or other time-consuming tasks, will they use this global timeout, or do they require separate timeout configurations?

I've noticed that some operations allow overriding the timeout:

# Scan operation
scanner = scan(
    client,
    index=config.ES_INDEX_PREFIX + index_name,
    query=self.get_search_body(metadata),
    size=1000,
    scroll=config.SCROLL_TIMEOUT,
    request_timeout=config.REQUEST_TIMEOUT,
)

# Delete operation
client.delete_by_query(
    index=config.ES_INDEX_PREFIX + index_name,
    body={"query": {"match_all": {}}},
    timeout="10m"
)
  1. Is there a way to set a global timeout in the Elasticsearch client that applies to all operations by default, without needing to specify it for each individual operation?

Any insights into how timeout configuration works across different Elasticsearch operations would be greatly appreciated. Thanks!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.