sfeos-helpers 6.6.0__tar.gz → 6.7.1__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.
- {sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/PKG-INFO +14 -2
- sfeos_helpers-6.7.1/README.md +34 -0
- {sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/pyproject.toml +1 -1
- {sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/filter/README.md +5 -2
- {sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/filter/client.py +46 -16
- {sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/version.py +1 -1
- sfeos_helpers-6.6.0/README.md +0 -22
- {sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/.gitignore +0 -0
- {sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/aggregation/README.md +0 -0
- {sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/aggregation/__init__.py +0 -0
- {sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/aggregation/client.py +0 -0
- {sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/aggregation/format.py +0 -0
- {sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/database/README.md +0 -0
- {sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/database/__init__.py +0 -0
- {sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/database/datetime.py +0 -0
- {sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/database/document.py +0 -0
- {sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/database/index.py +0 -0
- {sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/database/mapping.py +0 -0
- {sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/database/query.py +0 -0
- {sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/database/utils.py +0 -0
- {sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/filter/__init__.py +0 -0
- {sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/filter/cql2.py +0 -0
- {sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/filter/transform.py +0 -0
- {sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/mappings.py +0 -0
- {sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/models/patch.py +0 -0
- {sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/search_engine/__init__.py +0 -0
- {sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/search_engine/base.py +0 -0
- {sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/search_engine/factory.py +0 -0
- {sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/search_engine/index_operations.py +0 -0
- {sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/search_engine/inserters.py +0 -0
- {sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/search_engine/managers.py +0 -0
- {sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/search_engine/selection/__init__.py +0 -0
- {sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/search_engine/selection/base.py +0 -0
- {sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/search_engine/selection/cache_manager.py +0 -0
- {sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/search_engine/selection/factory.py +0 -0
- {sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/search_engine/selection/selectors.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sfeos_helpers
|
|
3
|
-
Version: 6.
|
|
3
|
+
Version: 6.7.1
|
|
4
4
|
Summary: Helper library for the Elasticsearch and Opensearch stac-fastapi backends.
|
|
5
5
|
Project-URL: Homepage, https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch
|
|
6
6
|
License: MIT
|
|
@@ -16,11 +16,23 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.13
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.14
|
|
18
18
|
Requires-Python: >=3.9
|
|
19
|
-
Requires-Dist: stac-fastapi-core==6.
|
|
19
|
+
Requires-Dist: stac-fastapi-core==6.7.1
|
|
20
20
|
Description-Content-Type: text/markdown
|
|
21
21
|
|
|
22
22
|
# sfeos-helpers
|
|
23
23
|
|
|
24
|
+
<p align="left">
|
|
25
|
+
<img src="https://raw.githubusercontent.com/stac-utils/stac-fastapi-elasticsearch-opensearch/refs/heads/main/assets/sfeos.png" width=1000>
|
|
26
|
+
</p>
|
|
27
|
+
|
|
28
|
+
[](https://pepy.tech/project/stac-fastapi-core)
|
|
29
|
+
[](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/graphs/contributors)
|
|
30
|
+
[](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/stargazers)
|
|
31
|
+
[](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/network/members)
|
|
32
|
+
[](https://pypi.org/project/stac-fastapi-elasticsearch/)
|
|
33
|
+
[](https://github.com/radiantearth/stac-spec/tree/v1.1.0)
|
|
34
|
+
[](https://github.com/stac-utils/stac-fastapi)
|
|
35
|
+
|
|
24
36
|
Helper utilities for the stac-fastapi project. For full documentation, please see the [main README](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/blob/main/README.md).
|
|
25
37
|
|
|
26
38
|
## Package Information
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# sfeos-helpers
|
|
2
|
+
|
|
3
|
+
<p align="left">
|
|
4
|
+
<img src="https://raw.githubusercontent.com/stac-utils/stac-fastapi-elasticsearch-opensearch/refs/heads/main/assets/sfeos.png" width=1000>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
[](https://pepy.tech/project/stac-fastapi-core)
|
|
8
|
+
[](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/graphs/contributors)
|
|
9
|
+
[](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/stargazers)
|
|
10
|
+
[](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/network/members)
|
|
11
|
+
[](https://pypi.org/project/stac-fastapi-elasticsearch/)
|
|
12
|
+
[](https://github.com/radiantearth/stac-spec/tree/v1.1.0)
|
|
13
|
+
[](https://github.com/stac-utils/stac-fastapi)
|
|
14
|
+
|
|
15
|
+
Helper utilities for the stac-fastapi project. For full documentation, please see the [main README](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/blob/main/README.md).
|
|
16
|
+
|
|
17
|
+
## Package Information
|
|
18
|
+
|
|
19
|
+
- **Package name**: sfeos-helpers
|
|
20
|
+
- **Description**: Helper utilities for the stac-fastapi project.
|
|
21
|
+
- **Documentation**: [https://stac-utils.github.io/stac-fastapi-elasticsearch-opensearch/](https://stac-utils.github.io/stac-fastapi-elasticsearch-opensearch/)
|
|
22
|
+
- **Source**: [GitHub Repository](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/)
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
This package is a dependency of stac-fastapi-elasticsearch and stac-fastapi-opensearch and is typically installed automatically.
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install stac-fastapi-elasticsearch # or stac-fastapi-opensearch
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
For detailed usage and examples, please refer to the [main documentation](https://stac-utils.github.io/stac-fastapi-elasticsearch-opensearch/).
|
|
@@ -9,10 +9,12 @@ between the two implementations.
|
|
|
9
9
|
The filter package is organized into three main modules:
|
|
10
10
|
|
|
11
11
|
- **cql2.py**: Contains functions for converting CQL2 patterns to Elasticsearch/OpenSearch compatible formats
|
|
12
|
+
|
|
12
13
|
- [cql2_like_to_es](cci:1://file:///home/computer/Code/stac-fastapi-elasticsearch-opensearch/stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/filter.py:59:0-75:5): Converts CQL2 "LIKE" characters to Elasticsearch "wildcard" characters
|
|
13
|
-
- [_replace_like_patterns](cci:1://file:///home/computer/Code/stac-fastapi-elasticsearch-opensearch/stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/filter.py:51:0-56:71): Helper function for pattern replacement
|
|
14
|
+
- [\_replace_like_patterns](cci:1://file:///home/computer/Code/stac-fastapi-elasticsearch-opensearch/stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/filter.py:51:0-56:71): Helper function for pattern replacement
|
|
14
15
|
|
|
15
16
|
- **transform.py**: Contains functions for transforming CQL2 queries to Elasticsearch/OpenSearch query DSL
|
|
17
|
+
|
|
16
18
|
- [to_es_field](cci:1://file:///home/computer/Code/stac-fastapi-elasticsearch-opensearch/stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/filter.py:83:0-93:47): Maps field names using queryables mapping
|
|
17
19
|
- [to_es](cci:1://file:///home/computer/Code/stac-fastapi-elasticsearch-opensearch/stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/filter.py:96:0-201:13): Transforms CQL2 query structures to Elasticsearch/OpenSearch query DSL
|
|
18
20
|
|
|
@@ -24,4 +26,5 @@ The filter package is organized into three main modules:
|
|
|
24
26
|
Import the necessary components from the filter package:
|
|
25
27
|
|
|
26
28
|
```python
|
|
27
|
-
from stac_fastapi.sfeos_helpers.filter import cql2_like_to_es, to_es, EsAsyncBaseFiltersClient
|
|
29
|
+
from stac_fastapi.sfeos_helpers.filter import cql2_like_to_es, to_es, EsAsyncBaseFiltersClient
|
|
30
|
+
```
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"""Filter client implementation for Elasticsearch/OpenSearch."""
|
|
2
2
|
|
|
3
|
+
import os
|
|
3
4
|
from collections import deque
|
|
4
|
-
from typing import Any,
|
|
5
|
+
from typing import Any, Optional
|
|
5
6
|
|
|
6
7
|
import attr
|
|
7
8
|
from fastapi import Request
|
|
@@ -18,9 +19,29 @@ class EsAsyncBaseFiltersClient(AsyncBaseFiltersClient):
|
|
|
18
19
|
|
|
19
20
|
database: BaseDatabaseLogic = attr.ib()
|
|
20
21
|
|
|
22
|
+
@staticmethod
|
|
23
|
+
def _get_excluded_from_queryables() -> set[str]:
|
|
24
|
+
"""Get fields to exclude from queryables endpoint and filtering.
|
|
25
|
+
|
|
26
|
+
Reads from EXCLUDED_FROM_QUERYABLES environment variable.
|
|
27
|
+
Supports comma-separated list of field names.
|
|
28
|
+
|
|
29
|
+
Example:
|
|
30
|
+
EXCLUDED_FROM_QUERYABLES="auth:schemes,storage:schemes"
|
|
31
|
+
|
|
32
|
+
Returns:
|
|
33
|
+
Set[str]: Set of field names to exclude from queryables
|
|
34
|
+
"""
|
|
35
|
+
excluded = os.getenv("EXCLUDED_FROM_QUERYABLES", "")
|
|
36
|
+
if not excluded:
|
|
37
|
+
return set()
|
|
38
|
+
return {field.strip() for field in excluded.split(",") if field.strip()}
|
|
39
|
+
|
|
21
40
|
async def get_queryables(
|
|
22
|
-
self,
|
|
23
|
-
|
|
41
|
+
self,
|
|
42
|
+
collection_id: Optional[str] = None, # noqa: UP045
|
|
43
|
+
**kwargs: Any,
|
|
44
|
+
) -> dict[str, Any]:
|
|
24
45
|
"""Get the queryables available for the given collection_id.
|
|
25
46
|
|
|
26
47
|
If collection_id is None, returns the intersection of all
|
|
@@ -38,21 +59,23 @@ class EsAsyncBaseFiltersClient(AsyncBaseFiltersClient):
|
|
|
38
59
|
Returns:
|
|
39
60
|
Dict[str, Any]: A dictionary containing the queryables for the given collection.
|
|
40
61
|
"""
|
|
41
|
-
request: Optional[Request] = kwargs.get("request")
|
|
42
|
-
url_str
|
|
43
|
-
|
|
62
|
+
request: Optional[Request] = kwargs.get("request") # noqa: UP045
|
|
63
|
+
url_str = str(request.url) if request else ""
|
|
64
|
+
|
|
65
|
+
queryables: dict[str, Any] = {
|
|
44
66
|
"$schema": "https://json-schema.org/draft-07/schema",
|
|
45
|
-
"$id":
|
|
67
|
+
"$id": url_str,
|
|
46
68
|
"type": "object",
|
|
47
69
|
"title": "Queryables for STAC API",
|
|
48
70
|
"description": "Queryable names for the STAC API Item Search filter.",
|
|
49
71
|
"properties": DEFAULT_QUERYABLES,
|
|
50
72
|
"additionalProperties": True,
|
|
51
73
|
}
|
|
74
|
+
|
|
52
75
|
if not collection_id:
|
|
53
76
|
return queryables
|
|
54
77
|
|
|
55
|
-
properties
|
|
78
|
+
properties = queryables["properties"].copy()
|
|
56
79
|
queryables.update(
|
|
57
80
|
{
|
|
58
81
|
"properties": properties,
|
|
@@ -62,8 +85,9 @@ class EsAsyncBaseFiltersClient(AsyncBaseFiltersClient):
|
|
|
62
85
|
|
|
63
86
|
mapping_data = await self.database.get_items_mapping(collection_id)
|
|
64
87
|
mapping_properties = next(iter(mapping_data.values()))["mappings"]["properties"]
|
|
65
|
-
stack: deque[
|
|
66
|
-
enum_fields:
|
|
88
|
+
stack: deque[tuple[str, dict[str, Any]]] = deque(mapping_properties.items())
|
|
89
|
+
enum_fields: dict[str, dict[str, Any]] = {}
|
|
90
|
+
excluded_fields = self._get_excluded_from_queryables()
|
|
67
91
|
|
|
68
92
|
while stack:
|
|
69
93
|
field_fqn, field_def = stack.popleft()
|
|
@@ -75,11 +99,16 @@ class EsAsyncBaseFiltersClient(AsyncBaseFiltersClient):
|
|
|
75
99
|
(f"{field_fqn}.{k}", v)
|
|
76
100
|
for k, v in field_properties.items()
|
|
77
101
|
if v.get("enabled", True)
|
|
102
|
+
and f"{field_fqn}.{k}" not in excluded_fields
|
|
78
103
|
)
|
|
79
104
|
|
|
80
105
|
# Skip non-indexed or disabled fields
|
|
81
106
|
field_type = field_def.get("type")
|
|
82
|
-
if
|
|
107
|
+
if (
|
|
108
|
+
not field_type
|
|
109
|
+
or not field_def.get("enabled", True)
|
|
110
|
+
or field_fqn in excluded_fields
|
|
111
|
+
):
|
|
83
112
|
continue
|
|
84
113
|
|
|
85
114
|
# Fields in Item Properties should be exposed with their un-prefixed names,
|
|
@@ -88,7 +117,7 @@ class EsAsyncBaseFiltersClient(AsyncBaseFiltersClient):
|
|
|
88
117
|
field_name = field_fqn.removeprefix("properties.")
|
|
89
118
|
|
|
90
119
|
# Generate field properties
|
|
91
|
-
field_result = ALL_QUERYABLES.get(field_name, {})
|
|
120
|
+
field_result = ALL_QUERYABLES.get(field_name, {}).copy()
|
|
92
121
|
properties[field_name] = field_result
|
|
93
122
|
|
|
94
123
|
field_name_human = field_name.replace("_", " ").title()
|
|
@@ -104,9 +133,10 @@ class EsAsyncBaseFiltersClient(AsyncBaseFiltersClient):
|
|
|
104
133
|
enum_fields[field_fqn] = field_result
|
|
105
134
|
|
|
106
135
|
if enum_fields:
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
)
|
|
110
|
-
|
|
136
|
+
unique_values = await self.database.get_items_unique_values(
|
|
137
|
+
collection_id, enum_fields
|
|
138
|
+
)
|
|
139
|
+
for field_fqn, values in unique_values.items():
|
|
140
|
+
enum_fields[field_fqn]["enum"] = values
|
|
111
141
|
|
|
112
142
|
return queryables
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"""library version."""
|
|
2
|
-
__version__ = "6.
|
|
2
|
+
__version__ = "6.7.1"
|
sfeos_helpers-6.6.0/README.md
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# sfeos-helpers
|
|
2
|
-
|
|
3
|
-
Helper utilities for the stac-fastapi project. For full documentation, please see the [main README](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/blob/main/README.md).
|
|
4
|
-
|
|
5
|
-
## Package Information
|
|
6
|
-
|
|
7
|
-
- **Package name**: sfeos-helpers
|
|
8
|
-
- **Description**: Helper utilities for the stac-fastapi project.
|
|
9
|
-
- **Documentation**: [https://stac-utils.github.io/stac-fastapi-elasticsearch-opensearch/](https://stac-utils.github.io/stac-fastapi-elasticsearch-opensearch/)
|
|
10
|
-
- **Source**: [GitHub Repository](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/)
|
|
11
|
-
|
|
12
|
-
## Installation
|
|
13
|
-
|
|
14
|
-
This package is a dependency of stac-fastapi-elasticsearch and stac-fastapi-opensearch and is typically installed automatically.
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
pip install stac-fastapi-elasticsearch # or stac-fastapi-opensearch
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## Quick Start
|
|
21
|
-
|
|
22
|
-
For detailed usage and examples, please refer to the [main documentation](https://stac-utils.github.io/stac-fastapi-elasticsearch-opensearch/).
|
|
File without changes
|
{sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/aggregation/README.md
RENAMED
|
File without changes
|
{sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/aggregation/__init__.py
RENAMED
|
File without changes
|
{sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/aggregation/client.py
RENAMED
|
File without changes
|
{sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/aggregation/format.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/search_engine/__init__.py
RENAMED
|
File without changes
|
{sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/search_engine/base.py
RENAMED
|
File without changes
|
{sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/search_engine/factory.py
RENAMED
|
File without changes
|
|
File without changes
|
{sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/search_engine/inserters.py
RENAMED
|
File without changes
|
{sfeos_helpers-6.6.0 → sfeos_helpers-6.7.1}/stac_fastapi/sfeos_helpers/search_engine/managers.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|