Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Added
- Option to configure multiple Elasticsearch/OpenSearch hosts and enable `http_compress`. [#349](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/349)

### Changed

## [v3.2.4] - 2025-03-14
Expand Down
11 changes: 9 additions & 2 deletions stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ def _es_config() -> Dict[str, Any]:
scheme = "https" if use_ssl else "http"

# Configure the hosts parameter with the correct scheme
hosts = [f"{scheme}://{os.getenv('ES_HOST')}:{os.getenv('ES_PORT')}"]
hosts = [
f"{scheme}://{host.strip()}:{os.getenv('ES_PORT')}"
for host in os.getenv("ES_HOST").split(",")
]

# Initialize the configuration dictionary
config = {
config: Dict[str, Any] = {
"hosts": hosts,
"headers": {"accept": "application/vnd.elasticsearch+json; compatible-with=7"},
}
Expand All @@ -34,6 +37,10 @@ def _es_config() -> Dict[str, Any]:

config["headers"] = headers

http_compress = os.getenv("ES_HTTP_COMPRESS", "true").lower() == "true"
if http_compress:
config["http_compress"] = True

# Explicitly exclude SSL settings when not using SSL
if not use_ssl:
return config
Expand Down
11 changes: 9 additions & 2 deletions stac_fastapi/opensearch/stac_fastapi/opensearch/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,21 @@ def _es_config() -> Dict[str, Any]:
scheme = "https" if use_ssl else "http"

# Configure the hosts parameter with the correct scheme
hosts = [f"{scheme}://{os.getenv('ES_HOST')}:{os.getenv('ES_PORT')}"]
hosts = [
f"{scheme}://{host.strip()}:{os.getenv('ES_PORT')}"
for host in os.getenv("ES_HOST").split(",")
]

# Initialize the configuration dictionary
config = {
config: Dict[str, Any] = {
"hosts": hosts,
"headers": {"accept": "application/json", "Content-Type": "application/json"},
}

http_compress = os.getenv("ES_HTTP_COMPRESS", "true").lower() == "true"
if http_compress:
config["http_compress"] = True

# Explicitly exclude SSL settings when not using SSL
if not use_ssl:
return config
Expand Down