Skip to content

Commit 21da4a8

Browse files
authored
Merge branch 'main' into main
2 parents fe568ee + 353210d commit 21da4a8

File tree

9 files changed

+46
-11
lines changed

9 files changed

+46
-11
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ repos:
1616
# E501 let black handle all line length decisions
1717
# W503 black conflicts with "line break before operator" rule
1818
# E203 black conflicts with "whitespace before ':'" rule
19-
'--ignore=E501,W503,E203,C901' ]
19+
'--ignore=E501,W503,E203,C901,E231' ]
2020
- repo: https://github.com/pre-commit/mirrors-mypy
2121
rev: v0.991
2222
hooks:

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77

88
## [Unreleased]
99

10+
### Added
11+
1012
### Changed
1113

14+
## [v3.2.5] - 2025-04-07
15+
16+
### Added
17+
18+
- Option to configure multiple Elasticsearch/OpenSearch hosts and enable `http_compress`. [#349](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/349)
19+
1220
## [v3.2.4] - 2025-03-14
1321

1422
### Added
@@ -299,7 +307,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
299307
- Use genexp in execute_search and get_all_collections to return results.
300308
- Added db_to_stac serializer to item_collection method in core.py.
301309

302-
[Unreleased]: https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v3.2.4...main
310+
[Unreleased]: https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v3.2.5...main
311+
[v3.2.5]: https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v3.2.4...v3.2.5
303312
[v3.2.4]: https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v3.2.3...v3.2.4
304313
[v3.2.3]: https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v3.2.2...v3.2.3
305314
[v3.2.2]: https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v3.2.1...v3.2.2
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""library version."""
2-
__version__ = "3.2.4"
2+
__version__ = "3.2.5"

stac_fastapi/elasticsearch/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
desc = f.read()
77

88
install_requires = [
9-
"stac-fastapi.core==3.2.4",
9+
"stac-fastapi.core==3.2.5",
1010
"elasticsearch[async]==8.11.0",
1111
"elasticsearch-dsl==8.11.0",
1212
"uvicorn",

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/config.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,19 @@ def _es_config() -> Dict[str, Any]:
1616
scheme = "https" if use_ssl else "http"
1717

1818
# Configure the hosts parameter with the correct scheme
19-
hosts = [f"{scheme}://{os.getenv('ES_HOST')}:{os.getenv('ES_PORT')}"]
19+
es_hosts = os.getenv(
20+
"ES_HOST", "localhost"
21+
).strip() # Default to localhost if ES_HOST is not set
22+
es_port = os.getenv("ES_PORT", "9200") # Default to 9200 if ES_PORT is not set
23+
24+
# Validate ES_HOST
25+
if not es_hosts:
26+
raise ValueError("ES_HOST environment variable is empty or invalid.")
27+
28+
hosts = [f"{scheme}://{host.strip()}:{es_port}" for host in es_hosts.split(",")]
2029

2130
# Initialize the configuration dictionary
22-
config = {
31+
config: Dict[str, Any] = {
2332
"hosts": hosts,
2433
"headers": {"accept": "application/vnd.elasticsearch+json; compatible-with=7"},
2534
}
@@ -34,6 +43,10 @@ def _es_config() -> Dict[str, Any]:
3443

3544
config["headers"] = headers
3645

46+
http_compress = os.getenv("ES_HTTP_COMPRESS", "true").lower() == "true"
47+
if http_compress:
48+
config["http_compress"] = True
49+
3750
# Explicitly exclude SSL settings when not using SSL
3851
if not use_ssl:
3952
return config
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""library version."""
2-
__version__ = "3.2.4"
2+
__version__ = "3.2.5"

stac_fastapi/opensearch/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
desc = f.read()
77

88
install_requires = [
9-
"stac-fastapi.core==3.2.4",
9+
"stac-fastapi.core==3.2.5",
1010
"opensearch-py==2.4.2",
1111
"opensearch-py[async]==2.4.2",
1212
"uvicorn",

stac_fastapi/opensearch/stac_fastapi/opensearch/config.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,27 @@ def _es_config() -> Dict[str, Any]:
1515
scheme = "https" if use_ssl else "http"
1616

1717
# Configure the hosts parameter with the correct scheme
18-
hosts = [f"{scheme}://{os.getenv('ES_HOST')}:{os.getenv('ES_PORT')}"]
18+
es_hosts = os.getenv(
19+
"ES_HOST", "localhost"
20+
).strip() # Default to localhost if ES_HOST is not set
21+
es_port = os.getenv("ES_PORT", "9200") # Default to 9200 if ES_PORT is not set
22+
23+
# Validate ES_HOST
24+
if not es_hosts:
25+
raise ValueError("ES_HOST environment variable is empty or invalid.")
26+
27+
hosts = [f"{scheme}://{host.strip()}:{es_port}" for host in es_hosts.split(",")]
1928

2029
# Initialize the configuration dictionary
21-
config = {
30+
config: Dict[str, Any] = {
2231
"hosts": hosts,
2332
"headers": {"accept": "application/json", "Content-Type": "application/json"},
2433
}
2534

35+
http_compress = os.getenv("ES_HTTP_COMPRESS", "true").lower() == "true"
36+
if http_compress:
37+
config["http_compress"] = True
38+
2639
# Explicitly exclude SSL settings when not using SSL
2740
if not use_ssl:
2841
return config
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""library version."""
2-
__version__ = "3.2.4"
2+
__version__ = "3.2.5"

0 commit comments

Comments
 (0)