Skip to content

Commit 86a72e7

Browse files
committed
Merge branch 'main' into collection_update_endpoint
2 parents c023546 + 61c01cb commit 86a72e7

File tree

19 files changed

+615
-218
lines changed

19 files changed

+615
-218
lines changed

.github/workflows/cicd.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
services:
1717

1818
elasticsearch_8_svc:
19-
image: docker.elastic.co/elasticsearch/elasticsearch:8.1.3
19+
image: docker.elastic.co/elasticsearch/elasticsearch:8.11.0
2020
env:
2121
cluster.name: stac-cluster
2222
node.name: es01
@@ -58,7 +58,7 @@ jobs:
5858

5959
# Setup Python (faster than using Python container)
6060
- name: Setup Python
61-
uses: actions/setup-python@v4
61+
uses: actions/setup-python@v5
6262
with:
6363
python-version: ${{ matrix.python-version }}
6464
- name: Lint code

CHANGELOG.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,39 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
99

1010
### Added
1111

12-
- Collection-level Assets to the CollectionSerializer [#148](https://github.com/stac-utils/stac-fastapi-elasticsearch/issues/148)
12+
### Changed
13+
14+
- Elasticsearch drivers from 7.17.9 to 8.11.0 [#169](https://github.com/stac-utils/stac-fastapi-elasticsearch/pull/169)
15+
16+
### Fixed
17+
18+
- Exclude unset fields in search response [#166](https://github.com/stac-utils/stac-fastapi-elasticsearch/issues/166)
19+
- Upgrade stac-fastapi to v2.4.9 [#172](https://github.com/stac-utils/stac-fastapi-elasticsearch/pull/172)
20+
21+
## [v1.0.0]
1322

1423
### Added
1524

25+
- Collection-level Assets to the CollectionSerializer [#148](https://github.com/stac-utils/stac-fastapi-elasticsearch/issues/148)
26+
- Pagination for /collections - GET all collections - route [#164](https://github.com/stac-utils/stac-fastapi-elasticsearch/pull/164)
1627
- Examples folder with example docker setup for running sfes from pip [#147](https://github.com/stac-utils/stac-fastapi-elasticsearch/pull/147)
28+
- GET /search filter extension queries [#163](https://github.com/stac-utils/stac-fastapi-elasticsearch/pull/163)
29+
- Added support for GET /search intersection queries [#158](https://github.com/stac-utils/stac-fastapi-elasticsearch/issues/158)
1730

1831
### Changed
32+
33+
- Update elasticsearch version from 8.1.3 to 8.10.4 in cicd, gh actions [#164](https://github.com/stac-utils/stac-fastapi-elasticsearch/pull/164)
34+
- Updated core stac-fastapi libraries to 2.4.8 from 2.4.3 [#151](https://github.com/stac-utils/stac-fastapi-elasticsearch/pull/151)
35+
- Use aliases on Elasticsearch indices, add number suffix in index name. [#152](https://github.com/stac-utils/stac-fastapi-elasticsearch/pull/152)
36+
1937
### Fixed
2038

2139
- Corrected the closing of client connections in ES index management functions [#132](https://github.com/stac-utils/stac-fastapi-elasticsearch/issues/132)
2240
- Corrected the automatic converstion of float values to int when building Filter Clauses [#135](https://github.com/stac-utils/stac-fastapi-elasticsearch/issues/135)
41+
- Do not index `proj:geometry` field as geo_shape [#154](https://github.com/stac-utils/stac-fastapi-elasticsearch/issues/154)
2342
- Remove unsupported characters from Elasticsearch index names [#153](https://github.com/stac-utils/stac-fastapi-elasticsearch/issues/153)
43+
- Fixed GET /search sortby requests [#25](https://github.com/stac-utils/stac-fastapi-elasticsearch/issues/25)
44+
2445

2546
## [v0.3.0]
2647

@@ -34,11 +55,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
3455
- Fields Extension [#129](https://github.com/stac-utils/stac-fastapi-elasticsearch/pull/129)
3556
- Support for Python 3.11 [#131](https://github.com/stac-utils/stac-fastapi-elasticsearch/pull/131)
3657

37-
3858
### Changed
3959

4060
- Updated core stac-fastapi libraries to 2.4.3 from 2.3.0 [#127](https://github.com/stac-utils/stac-fastapi-elasticsearch/pull/127)
4161

62+
4263
## [v0.2.0]
4364

4465
### Added
@@ -61,6 +82,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
6182
- When using bulk ingest, items will continue to be ingested if any of them fail. Previously, the call would fail
6283
immediately if any items failed.
6384

85+
6486
## [v0.1.0]
6587

6688
### Changed
@@ -72,7 +94,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
7294
- Use genexp in execute_search and get_all_collections to return results.
7395
- Added db_to_stac serializer to item_collection method in core.py.
7496

75-
[Unreleased]: <https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v0.3.0...main>
97+
98+
[Unreleased]: <https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v1.0.0...main>
99+
[v1.0.0]: <https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v0.3.0...v1.0.0>
76100
[v0.3.0]: <https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v0.2.0...v0.3.0>
77101
[v0.2.0]: <https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v0.1.0...v0.2.0>
78102
[v0.1.0]: <https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v0.1.0>

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,17 @@ curl -X "POST" "http://localhost:8080/collections" \
6161
```
6262

6363
Note: this "Collections Transaction" behavior is not part of the STAC API, but may be soon.
64+
65+
66+
## Collection pagination
67+
68+
The collections route handles optional `limit` and `token` parameters. The `links` field that is
69+
returned from the `/collections` route contains a `next` link with the token that can be used to
70+
get the next page of results.
6471

72+
```shell
73+
curl -X "GET" "http://localhost:8080/collections?limit=1&token=example_token"
74+
```
6575

6676
## Testing
6777

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.3.0
1+
1.0.0

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ services:
3131

3232
elasticsearch:
3333
container_name: es-container
34-
image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION:-8.1.3}
34+
image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION:-8.11.0}
3535
environment:
3636
ES_JAVA_OPTS: -Xms512m -Xmx1g
3737
volumes:

stac_fastapi/elasticsearch/setup.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@
88
install_requires = [
99
"fastapi",
1010
"attrs",
11-
"pydantic[dotenv]",
11+
"pydantic[dotenv]<2",
1212
"stac_pydantic==2.0.*",
13-
"stac-fastapi.types==2.4.3",
14-
"stac-fastapi.api==2.4.3",
15-
"stac-fastapi.extensions==2.4.3",
16-
"elasticsearch[async]==7.17.9",
17-
"elasticsearch-dsl==7.4.1",
13+
"stac-fastapi.types==2.4.9",
14+
"stac-fastapi.api==2.4.9",
15+
"stac-fastapi.extensions==2.4.9",
16+
"elasticsearch[async]==8.11.0",
17+
"elasticsearch-dsl==8.11.0",
1818
"pystac[validation]",
1919
"uvicorn",
20+
"orjson",
2021
"overrides",
2122
"starlette",
2223
"geojson-pydantic",

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/app.py

Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
"""FastAPI application."""
2-
from typing import List
3-
4-
import attr
5-
62
from stac_fastapi.api.app import StacApi
73
from stac_fastapi.api.models import create_get_request_model, create_post_request_model
84
from stac_fastapi.elasticsearch.config import ElasticsearchSettings
@@ -28,52 +24,15 @@
2824
settings = ElasticsearchSettings()
2925
session = Session.create_from_settings(settings)
3026

31-
32-
@attr.s
33-
class FixedSortExtension(SortExtension):
34-
"""SortExtension class fixed with correct paths, removing extra forward-slash."""
35-
36-
conformance_classes: List[str] = attr.ib(
37-
factory=lambda: ["https://api.stacspec.org/v1.0.0-beta.4/item-search#sort"]
38-
)
39-
40-
41-
@attr.s
42-
class FixedFilterExtension(FilterExtension):
43-
"""FilterExtension class fixed with correct paths, removing extra forward-slash."""
44-
45-
conformance_classes: List[str] = attr.ib(
46-
default=[
47-
"https://api.stacspec.org/v1.0.0-rc.1/item-search#filter",
48-
"http://www.opengis.net/spec/ogcapi-features-3/1.0/conf/filter",
49-
"http://www.opengis.net/spec/ogcapi-features-3/1.0/conf/features-filter",
50-
"http://www.opengis.net/spec/cql2/1.0/conf/cql2-text",
51-
"http://www.opengis.net/spec/cql2/1.0/conf/cql2-json",
52-
"http://www.opengis.net/spec/cql2/1.0/conf/basic-cql2",
53-
"http://www.opengis.net/spec/cql2/1.0/conf/basic-spatial-operators",
54-
]
55-
)
56-
client = attr.ib(factory=EsAsyncBaseFiltersClient)
57-
58-
59-
@attr.s
60-
class FixedQueryExtension(QueryExtension):
61-
"""Fixed Query Extension string."""
62-
63-
conformance_classes: List[str] = attr.ib(
64-
factory=lambda: ["https://api.stacspec.org/v1.0.0-beta.4/item-search#query"]
65-
)
66-
67-
6827
extensions = [
6928
TransactionExtension(client=TransactionsClient(session=session), settings=settings),
7029
BulkTransactionExtension(client=BulkTransactionsClient(session=session)),
7130
FieldsExtension(),
72-
FixedQueryExtension(),
73-
FixedSortExtension(),
31+
QueryExtension(),
32+
SortExtension(),
7433
TokenPaginationExtension(),
7534
ContextExtension(),
76-
FixedFilterExtension(),
35+
FilterExtension(client=EsAsyncBaseFiltersClient()),
7736
]
7837

7938
post_request_model = create_post_request_model(extensions)

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/config.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,43 @@
11
"""API configuration."""
22
import os
3+
import ssl
34
from typing import Any, Dict, Set
45

56
from elasticsearch import AsyncElasticsearch, Elasticsearch # type: ignore
67
from stac_fastapi.types.config import ApiSettings
78

89

910
def _es_config() -> Dict[str, Any]:
11+
# Determine the scheme (http or https)
12+
use_ssl = os.getenv("ES_USE_SSL", "true").lower() == "true"
13+
scheme = "https" if use_ssl else "http"
14+
15+
# Configure the hosts parameter with the correct scheme
16+
hosts = [f"{scheme}://{os.getenv('ES_HOST')}:{os.getenv('ES_PORT')}"]
17+
18+
# Initialize the configuration dictionary
1019
config = {
11-
"hosts": [{"host": os.getenv("ES_HOST"), "port": os.getenv("ES_PORT")}],
20+
"hosts": hosts,
1221
"headers": {"accept": "application/vnd.elasticsearch+json; compatible-with=7"},
13-
"use_ssl": True,
14-
"verify_certs": True,
1522
}
1623

17-
if (u := os.getenv("ES_USER")) and (p := os.getenv("ES_PASS")):
18-
config["http_auth"] = (u, p)
24+
# Explicitly exclude SSL settings when not using SSL
25+
if not use_ssl:
26+
return config
1927

20-
if (v := os.getenv("ES_USE_SSL")) and v == "false":
21-
config["use_ssl"] = False
28+
# Include SSL settings if using https
29+
config["ssl_version"] = ssl.TLSVersion.TLSv1_3 # type: ignore
30+
config["verify_certs"] = os.getenv("ES_VERIFY_CERTS", "true").lower() != "false" # type: ignore
2231

23-
if (v := os.getenv("ES_VERIFY_CERTS")) and v == "false":
24-
config["verify_certs"] = False
32+
# Include CA Certificates if verifying certs
33+
if config["verify_certs"]:
34+
config["ca_certs"] = os.getenv(
35+
"CURL_CA_BUNDLE", "/etc/ssl/certs/ca-certificates.crt"
36+
)
2537

26-
if v := os.getenv("CURL_CA_BUNDLE"):
27-
config["ca_certs"] = v
38+
# Handle authentication
39+
if (u := os.getenv("ES_USER")) and (p := os.getenv("ES_PASS")):
40+
config["http_auth"] = (u, p)
2841

2942
return config
3043

0 commit comments

Comments
 (0)