stac-fastapi-elasticsearch 4.0.0a1__tar.gz → 4.0.0a2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {stac_fastapi_elasticsearch-4.0.0a1 → stac_fastapi_elasticsearch-4.0.0a2}/PKG-INFO +19 -7
- {stac_fastapi_elasticsearch-4.0.0a1 → stac_fastapi_elasticsearch-4.0.0a2}/README.md +18 -6
- {stac_fastapi_elasticsearch-4.0.0a1 → stac_fastapi_elasticsearch-4.0.0a2}/setup.py +1 -1
- {stac_fastapi_elasticsearch-4.0.0a1 → stac_fastapi_elasticsearch-4.0.0a2}/stac_fastapi/elasticsearch/app.py +1 -1
- {stac_fastapi_elasticsearch-4.0.0a1 → stac_fastapi_elasticsearch-4.0.0a2}/stac_fastapi/elasticsearch/config.py +37 -9
- {stac_fastapi_elasticsearch-4.0.0a1 → stac_fastapi_elasticsearch-4.0.0a2}/stac_fastapi/elasticsearch/database_logic.py +14 -14
- stac_fastapi_elasticsearch-4.0.0a2/stac_fastapi/elasticsearch/version.py +2 -0
- {stac_fastapi_elasticsearch-4.0.0a1 → stac_fastapi_elasticsearch-4.0.0a2}/stac_fastapi_elasticsearch.egg-info/PKG-INFO +19 -7
- {stac_fastapi_elasticsearch-4.0.0a1 → stac_fastapi_elasticsearch-4.0.0a2}/stac_fastapi_elasticsearch.egg-info/requires.txt +1 -1
- stac_fastapi_elasticsearch-4.0.0a1/stac_fastapi/elasticsearch/version.py +0 -2
- {stac_fastapi_elasticsearch-4.0.0a1 → stac_fastapi_elasticsearch-4.0.0a2}/setup.cfg +0 -0
- {stac_fastapi_elasticsearch-4.0.0a1 → stac_fastapi_elasticsearch-4.0.0a2}/stac_fastapi/elasticsearch/__init__.py +0 -0
- {stac_fastapi_elasticsearch-4.0.0a1 → stac_fastapi_elasticsearch-4.0.0a2}/stac_fastapi_elasticsearch.egg-info/SOURCES.txt +0 -0
- {stac_fastapi_elasticsearch-4.0.0a1 → stac_fastapi_elasticsearch-4.0.0a2}/stac_fastapi_elasticsearch.egg-info/dependency_links.txt +0 -0
- {stac_fastapi_elasticsearch-4.0.0a1 → stac_fastapi_elasticsearch-4.0.0a2}/stac_fastapi_elasticsearch.egg-info/entry_points.txt +0 -0
- {stac_fastapi_elasticsearch-4.0.0a1 → stac_fastapi_elasticsearch-4.0.0a2}/stac_fastapi_elasticsearch.egg-info/not-zip-safe +0 -0
- {stac_fastapi_elasticsearch-4.0.0a1 → stac_fastapi_elasticsearch-4.0.0a2}/stac_fastapi_elasticsearch.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: stac_fastapi_elasticsearch
|
|
3
|
-
Version: 4.0.
|
|
3
|
+
Version: 4.0.0a2
|
|
4
4
|
Summary: An implementation of STAC API based on the FastAPI framework with both Elasticsearch and Opensearch.
|
|
5
5
|
Home-page: https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch
|
|
6
6
|
License: MIT
|
|
@@ -50,8 +50,18 @@ Provides-Extra: server
|
|
|
50
50
|
- There is [Postman](https://documenter.getpostman.com/view/12888943/2s8ZDSdRHA) documentation here for examples on how to run some of the API routes locally - after starting the elasticsearch backend via the compose.yml file.
|
|
51
51
|
- The `/examples` folder shows an example of running stac-fastapi-elasticsearch from PyPI in docker without needing any code from the repository. There is also a Postman collection here that you can load into Postman for testing the API routes.
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
|
|
54
|
+
### Performance Note
|
|
55
|
+
|
|
56
|
+
The `enable_direct_response` option is provided by the stac-fastapi core library (introduced in stac-fastapi 5.2.0) and is available in this project starting from v4.0.0.
|
|
57
|
+
|
|
58
|
+
**You can now control this setting via the `ENABLE_DIRECT_RESPONSE` environment variable.**
|
|
59
|
+
|
|
60
|
+
When enabled (`ENABLE_DIRECT_RESPONSE=true`), endpoints return Starlette Response objects directly, bypassing FastAPI's default serialization for improved performance. **However, all FastAPI dependencies (including authentication, custom status codes, and validation) are disabled for all routes.**
|
|
61
|
+
|
|
62
|
+
This mode is best suited for public or read-only APIs where authentication and custom logic are not required. Default is `false` for safety.
|
|
63
|
+
|
|
64
|
+
See: [issue #347](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/issues/347)
|
|
55
65
|
|
|
56
66
|
|
|
57
67
|
### To install from PyPI:
|
|
@@ -95,8 +105,9 @@ If you wish to use a different version, put the following in a
|
|
|
95
105
|
file named `.env` in the same directory you run Docker Compose from:
|
|
96
106
|
|
|
97
107
|
```shell
|
|
98
|
-
ELASTICSEARCH_VERSION=
|
|
99
|
-
OPENSEARCH_VERSION=2.11.
|
|
108
|
+
ELASTICSEARCH_VERSION=8.11.0
|
|
109
|
+
OPENSEARCH_VERSION=2.11.1
|
|
110
|
+
ENABLE_DIRECT_RESPONSE=false
|
|
100
111
|
```
|
|
101
112
|
The most recent Elasticsearch 7.x versions should also work. See the [opensearch-py docs](https://github.com/opensearch-project/opensearch-py/blob/main/COMPATIBILITY.md) for compatibility information.
|
|
102
113
|
|
|
@@ -121,8 +132,9 @@ You can customize additional settings in your `.env` file:
|
|
|
121
132
|
| `RELOAD` | Enable auto-reload for development. | `true` | Optional |
|
|
122
133
|
| `STAC_FASTAPI_RATE_LIMIT` | API rate limit per client. | `200/minute` | Optional |
|
|
123
134
|
| `BACKEND` | Tests-related variable | `elasticsearch` or `opensearch` based on the backend | Optional |
|
|
124
|
-
| `ELASTICSEARCH_VERSION`
|
|
125
|
-
| `
|
|
135
|
+
| `ELASTICSEARCH_VERSION` | Version of Elasticsearch to use. | `8.11.0` | Optional |
|
|
136
|
+
| `ENABLE_DIRECT_RESPONSE` | Enable direct response for maximum performance (disables all FastAPI dependencies, including authentication, custom status codes, and validation) | `false` | Optional |
|
|
137
|
+
| `OPENSEARCH_VERSION` | OpenSearch version | `2.11.1` | Optional |
|
|
126
138
|
|
|
127
139
|
> [!NOTE]
|
|
128
140
|
> The variables `ES_HOST`, `ES_PORT`, `ES_USE_SSL`, and `ES_VERIFY_CERTS` apply to both Elasticsearch and OpenSearch backends, so there is no need to rename the key names to `OS_` even if you're using OpenSearch.
|
|
@@ -29,8 +29,18 @@
|
|
|
29
29
|
- There is [Postman](https://documenter.getpostman.com/view/12888943/2s8ZDSdRHA) documentation here for examples on how to run some of the API routes locally - after starting the elasticsearch backend via the compose.yml file.
|
|
30
30
|
- The `/examples` folder shows an example of running stac-fastapi-elasticsearch from PyPI in docker without needing any code from the repository. There is also a Postman collection here that you can load into Postman for testing the API routes.
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
|
|
33
|
+
### Performance Note
|
|
34
|
+
|
|
35
|
+
The `enable_direct_response` option is provided by the stac-fastapi core library (introduced in stac-fastapi 5.2.0) and is available in this project starting from v4.0.0.
|
|
36
|
+
|
|
37
|
+
**You can now control this setting via the `ENABLE_DIRECT_RESPONSE` environment variable.**
|
|
38
|
+
|
|
39
|
+
When enabled (`ENABLE_DIRECT_RESPONSE=true`), endpoints return Starlette Response objects directly, bypassing FastAPI's default serialization for improved performance. **However, all FastAPI dependencies (including authentication, custom status codes, and validation) are disabled for all routes.**
|
|
40
|
+
|
|
41
|
+
This mode is best suited for public or read-only APIs where authentication and custom logic are not required. Default is `false` for safety.
|
|
42
|
+
|
|
43
|
+
See: [issue #347](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/issues/347)
|
|
34
44
|
|
|
35
45
|
|
|
36
46
|
### To install from PyPI:
|
|
@@ -74,8 +84,9 @@ If you wish to use a different version, put the following in a
|
|
|
74
84
|
file named `.env` in the same directory you run Docker Compose from:
|
|
75
85
|
|
|
76
86
|
```shell
|
|
77
|
-
ELASTICSEARCH_VERSION=
|
|
78
|
-
OPENSEARCH_VERSION=2.11.
|
|
87
|
+
ELASTICSEARCH_VERSION=8.11.0
|
|
88
|
+
OPENSEARCH_VERSION=2.11.1
|
|
89
|
+
ENABLE_DIRECT_RESPONSE=false
|
|
79
90
|
```
|
|
80
91
|
The most recent Elasticsearch 7.x versions should also work. See the [opensearch-py docs](https://github.com/opensearch-project/opensearch-py/blob/main/COMPATIBILITY.md) for compatibility information.
|
|
81
92
|
|
|
@@ -100,8 +111,9 @@ You can customize additional settings in your `.env` file:
|
|
|
100
111
|
| `RELOAD` | Enable auto-reload for development. | `true` | Optional |
|
|
101
112
|
| `STAC_FASTAPI_RATE_LIMIT` | API rate limit per client. | `200/minute` | Optional |
|
|
102
113
|
| `BACKEND` | Tests-related variable | `elasticsearch` or `opensearch` based on the backend | Optional |
|
|
103
|
-
| `ELASTICSEARCH_VERSION`
|
|
104
|
-
| `
|
|
114
|
+
| `ELASTICSEARCH_VERSION` | Version of Elasticsearch to use. | `8.11.0` | Optional |
|
|
115
|
+
| `ENABLE_DIRECT_RESPONSE` | Enable direct response for maximum performance (disables all FastAPI dependencies, including authentication, custom status codes, and validation) | `false` | Optional |
|
|
116
|
+
| `OPENSEARCH_VERSION` | OpenSearch version | `2.11.1` | Optional |
|
|
105
117
|
|
|
106
118
|
> [!NOTE]
|
|
107
119
|
> The variables `ES_HOST`, `ES_PORT`, `ES_USE_SSL`, and `ES_VERIFY_CERTS` apply to both Elasticsearch and OpenSearch backends, so there is no need to rename the key names to `OS_` even if you're using OpenSearch.
|
|
@@ -87,7 +87,7 @@ post_request_model = create_post_request_model(search_extensions)
|
|
|
87
87
|
api = StacApi(
|
|
88
88
|
title=os.getenv("STAC_FASTAPI_TITLE", "stac-fastapi-elasticsearch"),
|
|
89
89
|
description=os.getenv("STAC_FASTAPI_DESCRIPTION", "stac-fastapi-elasticsearch"),
|
|
90
|
-
api_version=os.getenv("STAC_FASTAPI_VERSION", "
|
|
90
|
+
api_version=os.getenv("STAC_FASTAPI_VERSION", "4.0.0a2"),
|
|
91
91
|
settings=settings,
|
|
92
92
|
extensions=extensions,
|
|
93
93
|
client=CoreClient(
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
"""API configuration."""
|
|
2
2
|
|
|
3
|
+
import logging
|
|
3
4
|
import os
|
|
4
5
|
import ssl
|
|
5
6
|
from typing import Any, Dict, Set
|
|
6
7
|
|
|
7
8
|
import certifi
|
|
9
|
+
from elasticsearch._async.client import AsyncElasticsearch
|
|
8
10
|
|
|
9
|
-
from elasticsearch import
|
|
11
|
+
from elasticsearch import Elasticsearch # type: ignore[attr-defined]
|
|
10
12
|
from stac_fastapi.core.base_settings import ApiBaseSettings
|
|
13
|
+
from stac_fastapi.core.utilities import get_bool_env
|
|
11
14
|
from stac_fastapi.types.config import ApiSettings
|
|
12
15
|
|
|
13
16
|
|
|
14
17
|
def _es_config() -> Dict[str, Any]:
|
|
15
18
|
# Determine the scheme (http or https)
|
|
16
|
-
use_ssl =
|
|
19
|
+
use_ssl = get_bool_env("ES_USE_SSL", default=True)
|
|
17
20
|
scheme = "https" if use_ssl else "http"
|
|
18
21
|
|
|
19
22
|
# Configure the hosts parameter with the correct scheme
|
|
@@ -44,7 +47,7 @@ def _es_config() -> Dict[str, Any]:
|
|
|
44
47
|
|
|
45
48
|
config["headers"] = headers
|
|
46
49
|
|
|
47
|
-
http_compress =
|
|
50
|
+
http_compress = get_bool_env("ES_HTTP_COMPRESS", default=True)
|
|
48
51
|
if http_compress:
|
|
49
52
|
config["http_compress"] = True
|
|
50
53
|
|
|
@@ -53,8 +56,8 @@ def _es_config() -> Dict[str, Any]:
|
|
|
53
56
|
return config
|
|
54
57
|
|
|
55
58
|
# Include SSL settings if using https
|
|
56
|
-
config["ssl_version"] = ssl.TLSVersion.TLSv1_3
|
|
57
|
-
config["verify_certs"] =
|
|
59
|
+
config["ssl_version"] = ssl.TLSVersion.TLSv1_3
|
|
60
|
+
config["verify_certs"] = get_bool_env("ES_VERIFY_CERTS", default=True)
|
|
58
61
|
|
|
59
62
|
# Include CA Certificates if verifying certs
|
|
60
63
|
if config["verify_certs"]:
|
|
@@ -71,11 +74,18 @@ _forbidden_fields: Set[str] = {"type"}
|
|
|
71
74
|
|
|
72
75
|
|
|
73
76
|
class ElasticsearchSettings(ApiSettings, ApiBaseSettings):
|
|
74
|
-
"""
|
|
77
|
+
"""
|
|
78
|
+
API settings.
|
|
79
|
+
|
|
80
|
+
Set enable_direct_response via the ENABLE_DIRECT_RESPONSE environment variable.
|
|
81
|
+
If enabled, all API routes use direct response for maximum performance, but ALL FastAPI dependencies (including authentication, custom status codes, and validation) are disabled.
|
|
82
|
+
Default is False for safety.
|
|
83
|
+
"""
|
|
75
84
|
|
|
76
|
-
# Fields which are defined by STAC but not included in the database model
|
|
77
85
|
forbidden_fields: Set[str] = _forbidden_fields
|
|
78
86
|
indexed_fields: Set[str] = {"datetime"}
|
|
87
|
+
enable_response_models: bool = False
|
|
88
|
+
enable_direct_response: bool = get_bool_env("ENABLE_DIRECT_RESPONSE", default=False)
|
|
79
89
|
|
|
80
90
|
@property
|
|
81
91
|
def create_client(self):
|
|
@@ -84,13 +94,31 @@ class ElasticsearchSettings(ApiSettings, ApiBaseSettings):
|
|
|
84
94
|
|
|
85
95
|
|
|
86
96
|
class AsyncElasticsearchSettings(ApiSettings, ApiBaseSettings):
|
|
87
|
-
"""
|
|
97
|
+
"""
|
|
98
|
+
API settings.
|
|
99
|
+
|
|
100
|
+
Set enable_direct_response via the ENABLE_DIRECT_RESPONSE environment variable.
|
|
101
|
+
If enabled, all API routes use direct response for maximum performance, but ALL FastAPI dependencies (including authentication, custom status codes, and validation) are disabled.
|
|
102
|
+
Default is False for safety.
|
|
103
|
+
"""
|
|
88
104
|
|
|
89
|
-
# Fields which are defined by STAC but not included in the database model
|
|
90
105
|
forbidden_fields: Set[str] = _forbidden_fields
|
|
91
106
|
indexed_fields: Set[str] = {"datetime"}
|
|
107
|
+
enable_response_models: bool = False
|
|
108
|
+
enable_direct_response: bool = get_bool_env("ENABLE_DIRECT_RESPONSE", default=False)
|
|
92
109
|
|
|
93
110
|
@property
|
|
94
111
|
def create_client(self):
|
|
95
112
|
"""Create async elasticsearch client."""
|
|
96
113
|
return AsyncElasticsearch(**_es_config())
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
# Warn at import if direct response is enabled (applies to either settings class)
|
|
117
|
+
if (
|
|
118
|
+
ElasticsearchSettings().enable_direct_response
|
|
119
|
+
or AsyncElasticsearchSettings().enable_direct_response
|
|
120
|
+
):
|
|
121
|
+
logging.basicConfig(level=logging.WARNING)
|
|
122
|
+
logging.warning(
|
|
123
|
+
"ENABLE_DIRECT_RESPONSE is True: All FastAPI dependencies (including authentication) are DISABLED for all routes!"
|
|
124
|
+
)
|
|
@@ -8,10 +8,11 @@ from copy import deepcopy
|
|
|
8
8
|
from typing import Any, Dict, Iterable, List, Optional, Tuple, Type
|
|
9
9
|
|
|
10
10
|
import attr
|
|
11
|
+
import elasticsearch.helpers as helpers
|
|
11
12
|
from elasticsearch.dsl import Q, Search
|
|
13
|
+
from elasticsearch.exceptions import NotFoundError as ESNotFoundError
|
|
12
14
|
from starlette.requests import Request
|
|
13
15
|
|
|
14
|
-
from elasticsearch import exceptions, helpers # type: ignore
|
|
15
16
|
from stac_fastapi.core.base_database_logic import BaseDatabaseLogic
|
|
16
17
|
from stac_fastapi.core.database_logic import (
|
|
17
18
|
COLLECTIONS_INDEX,
|
|
@@ -50,19 +51,18 @@ async def create_index_templates() -> None:
|
|
|
50
51
|
|
|
51
52
|
"""
|
|
52
53
|
client = AsyncElasticsearchSettings().create_client
|
|
53
|
-
await client.indices.
|
|
54
|
+
await client.indices.put_index_template(
|
|
54
55
|
name=f"template_{COLLECTIONS_INDEX}",
|
|
55
56
|
body={
|
|
56
57
|
"index_patterns": [f"{COLLECTIONS_INDEX}*"],
|
|
57
|
-
"mappings": ES_COLLECTIONS_MAPPINGS,
|
|
58
|
+
"template": {"mappings": ES_COLLECTIONS_MAPPINGS},
|
|
58
59
|
},
|
|
59
60
|
)
|
|
60
|
-
await client.indices.
|
|
61
|
+
await client.indices.put_index_template(
|
|
61
62
|
name=f"template_{ITEMS_INDEX_PREFIX}",
|
|
62
63
|
body={
|
|
63
64
|
"index_patterns": [f"{ITEMS_INDEX_PREFIX}*"],
|
|
64
|
-
"settings": ES_ITEMS_SETTINGS,
|
|
65
|
-
"mappings": ES_ITEMS_MAPPINGS,
|
|
65
|
+
"template": {"settings": ES_ITEMS_SETTINGS, "mappings": ES_ITEMS_MAPPINGS},
|
|
66
66
|
},
|
|
67
67
|
)
|
|
68
68
|
await client.close()
|
|
@@ -80,7 +80,7 @@ async def create_collection_index() -> None:
|
|
|
80
80
|
|
|
81
81
|
await client.options(ignore_status=400).indices.create(
|
|
82
82
|
index=f"{COLLECTIONS_INDEX}-000001",
|
|
83
|
-
|
|
83
|
+
body={"aliases": {COLLECTIONS_INDEX: {}}},
|
|
84
84
|
)
|
|
85
85
|
await client.close()
|
|
86
86
|
|
|
@@ -100,7 +100,7 @@ async def create_item_index(collection_id: str):
|
|
|
100
100
|
|
|
101
101
|
await client.options(ignore_status=400).indices.create(
|
|
102
102
|
index=f"{index_by_collection_id(collection_id)}-000001",
|
|
103
|
-
|
|
103
|
+
body={"aliases": {index_alias_by_collection_id(collection_id): {}}},
|
|
104
104
|
)
|
|
105
105
|
await client.close()
|
|
106
106
|
|
|
@@ -272,7 +272,7 @@ class DatabaseLogic(BaseDatabaseLogic):
|
|
|
272
272
|
index=index_alias_by_collection_id(collection_id),
|
|
273
273
|
id=mk_item_id(item_id, collection_id),
|
|
274
274
|
)
|
|
275
|
-
except
|
|
275
|
+
except ESNotFoundError:
|
|
276
276
|
raise NotFoundError(
|
|
277
277
|
f"Item {item_id} does not exist inside Collection {collection_id}"
|
|
278
278
|
)
|
|
@@ -512,7 +512,7 @@ class DatabaseLogic(BaseDatabaseLogic):
|
|
|
512
512
|
|
|
513
513
|
try:
|
|
514
514
|
es_response = await search_task
|
|
515
|
-
except
|
|
515
|
+
except ESNotFoundError:
|
|
516
516
|
raise NotFoundError(f"Collections '{collection_ids}' do not exist")
|
|
517
517
|
|
|
518
518
|
hits = es_response["hits"]["hits"]
|
|
@@ -595,7 +595,7 @@ class DatabaseLogic(BaseDatabaseLogic):
|
|
|
595
595
|
|
|
596
596
|
try:
|
|
597
597
|
db_response = await search_task
|
|
598
|
-
except
|
|
598
|
+
except ESNotFoundError:
|
|
599
599
|
raise NotFoundError(f"Collections '{collection_ids}' do not exist")
|
|
600
600
|
|
|
601
601
|
return db_response
|
|
@@ -721,7 +721,7 @@ class DatabaseLogic(BaseDatabaseLogic):
|
|
|
721
721
|
id=mk_item_id(item_id, collection_id),
|
|
722
722
|
refresh=refresh,
|
|
723
723
|
)
|
|
724
|
-
except
|
|
724
|
+
except ESNotFoundError:
|
|
725
725
|
raise NotFoundError(
|
|
726
726
|
f"Item {item_id} in collection {collection_id} not found"
|
|
727
727
|
)
|
|
@@ -741,7 +741,7 @@ class DatabaseLogic(BaseDatabaseLogic):
|
|
|
741
741
|
index=index_name, allow_no_indices=False
|
|
742
742
|
)
|
|
743
743
|
return mapping.body
|
|
744
|
-
except
|
|
744
|
+
except ESNotFoundError:
|
|
745
745
|
raise NotFoundError(f"Mapping for index {index_name} not found")
|
|
746
746
|
|
|
747
747
|
async def create_collection(self, collection: Collection, refresh: bool = False):
|
|
@@ -792,7 +792,7 @@ class DatabaseLogic(BaseDatabaseLogic):
|
|
|
792
792
|
collection = await self.client.get(
|
|
793
793
|
index=COLLECTIONS_INDEX, id=collection_id
|
|
794
794
|
)
|
|
795
|
-
except
|
|
795
|
+
except ESNotFoundError:
|
|
796
796
|
raise NotFoundError(f"Collection {collection_id} not found")
|
|
797
797
|
|
|
798
798
|
return collection["_source"]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: stac-fastapi-elasticsearch
|
|
3
|
-
Version: 4.0.
|
|
3
|
+
Version: 4.0.0a2
|
|
4
4
|
Summary: An implementation of STAC API based on the FastAPI framework with both Elasticsearch and Opensearch.
|
|
5
5
|
Home-page: https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch
|
|
6
6
|
License: MIT
|
|
@@ -50,8 +50,18 @@ Provides-Extra: server
|
|
|
50
50
|
- There is [Postman](https://documenter.getpostman.com/view/12888943/2s8ZDSdRHA) documentation here for examples on how to run some of the API routes locally - after starting the elasticsearch backend via the compose.yml file.
|
|
51
51
|
- The `/examples` folder shows an example of running stac-fastapi-elasticsearch from PyPI in docker without needing any code from the repository. There is also a Postman collection here that you can load into Postman for testing the API routes.
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
|
|
54
|
+
### Performance Note
|
|
55
|
+
|
|
56
|
+
The `enable_direct_response` option is provided by the stac-fastapi core library (introduced in stac-fastapi 5.2.0) and is available in this project starting from v4.0.0.
|
|
57
|
+
|
|
58
|
+
**You can now control this setting via the `ENABLE_DIRECT_RESPONSE` environment variable.**
|
|
59
|
+
|
|
60
|
+
When enabled (`ENABLE_DIRECT_RESPONSE=true`), endpoints return Starlette Response objects directly, bypassing FastAPI's default serialization for improved performance. **However, all FastAPI dependencies (including authentication, custom status codes, and validation) are disabled for all routes.**
|
|
61
|
+
|
|
62
|
+
This mode is best suited for public or read-only APIs where authentication and custom logic are not required. Default is `false` for safety.
|
|
63
|
+
|
|
64
|
+
See: [issue #347](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/issues/347)
|
|
55
65
|
|
|
56
66
|
|
|
57
67
|
### To install from PyPI:
|
|
@@ -95,8 +105,9 @@ If you wish to use a different version, put the following in a
|
|
|
95
105
|
file named `.env` in the same directory you run Docker Compose from:
|
|
96
106
|
|
|
97
107
|
```shell
|
|
98
|
-
ELASTICSEARCH_VERSION=
|
|
99
|
-
OPENSEARCH_VERSION=2.11.
|
|
108
|
+
ELASTICSEARCH_VERSION=8.11.0
|
|
109
|
+
OPENSEARCH_VERSION=2.11.1
|
|
110
|
+
ENABLE_DIRECT_RESPONSE=false
|
|
100
111
|
```
|
|
101
112
|
The most recent Elasticsearch 7.x versions should also work. See the [opensearch-py docs](https://github.com/opensearch-project/opensearch-py/blob/main/COMPATIBILITY.md) for compatibility information.
|
|
102
113
|
|
|
@@ -121,8 +132,9 @@ You can customize additional settings in your `.env` file:
|
|
|
121
132
|
| `RELOAD` | Enable auto-reload for development. | `true` | Optional |
|
|
122
133
|
| `STAC_FASTAPI_RATE_LIMIT` | API rate limit per client. | `200/minute` | Optional |
|
|
123
134
|
| `BACKEND` | Tests-related variable | `elasticsearch` or `opensearch` based on the backend | Optional |
|
|
124
|
-
| `ELASTICSEARCH_VERSION`
|
|
125
|
-
| `
|
|
135
|
+
| `ELASTICSEARCH_VERSION` | Version of Elasticsearch to use. | `8.11.0` | Optional |
|
|
136
|
+
| `ENABLE_DIRECT_RESPONSE` | Enable direct response for maximum performance (disables all FastAPI dependencies, including authentication, custom status codes, and validation) | `false` | Optional |
|
|
137
|
+
| `OPENSEARCH_VERSION` | OpenSearch version | `2.11.1` | Optional |
|
|
126
138
|
|
|
127
139
|
> [!NOTE]
|
|
128
140
|
> The variables `ES_HOST`, `ES_PORT`, `ES_USE_SSL`, and `ES_VERIFY_CERTS` apply to both Elasticsearch and OpenSearch backends, so there is no need to rename the key names to `OS_` even if you're using OpenSearch.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|