Skip to content

Commit af1a390

Browse files
Yuri ZmytrakovYuri Zmytrakov
authored andcommitted
docs: add USE_DATETIME env var to README, update CHANGELOG
1 parent 67fd1ca commit af1a390

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

CHANGELOG.md

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

99
## [Unreleased]
1010

11+
- Added `USE_DATETIME` environment variable behavior to set datetime filtering logic. [#443](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/443)
12+
1113
### Added
1214

1315
- Added the `ENV_MAX_LIMIT` environment variable to SFEOS, allowing overriding of the `MAX_LIMIT`, which controls the `?limit` parameter for returned items and STAC collections. [#434](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/434)
14-
- Updated the `format_datetime_range` function to support milliseconds. [#423](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/423)
1516

1617
### Changed
1718

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ You can customize additional settings in your `.env` file:
229229
| `ENABLE_TRANSACTIONS_EXTENSIONS` | Enables or disables the Transactions and Bulk Transactions API extensions. If set to `false`, the POST `/collections` route and related transaction endpoints (including bulk transaction operations) will be unavailable in the API. This is useful for deployments where mutating the catalog via the API should be prevented. | `true` | Optional |
230230
| `STAC_ITEM_LIMIT` | Sets the environment variable for result limiting to SFEOS for the number of returned items and STAC collections. | `10` | Optional |
231231
| `ENV_MAX_LIMIT` | Configures the environment variable in SFEOS to override the default `MAX_LIMIT`, which controls the limit parameter for returned items and STAC collections. | `10,000` | Optional |
232+
| `USE_DATETIME` | Configures the environment variable to control datetime filtering behavior. When `true`, searches by datetime field, and if datetime is `null` then by start/end datetime fields. When `false`, always searches only by start/end datetime fields. | true | Optional |
232233

233234
> [!NOTE]
234235
> The variables `ES_HOST`, `ES_PORT`, `ES_USE_SSL`, `ES_VERIFY_CERTS` and `ES_TIMEOUT` 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.

stac_fastapi/opensearch/stac_fastapi/opensearch/database_logic.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,10 @@ def apply_datetime_filter(
316316
"bool",
317317
filter=[
318318
Q("exists", field="properties.datetime"),
319-
Q("term", **{"properties__datetime": datetime_search["eq"]}),
319+
Q(
320+
"term",
321+
**{"properties__datetime": datetime_search["eq"]},
322+
),
320323
],
321324
),
322325
Q(
@@ -327,7 +330,9 @@ def apply_datetime_filter(
327330
Q("exists", field="properties.end_datetime"),
328331
Q(
329332
"range",
330-
properties__start_datetime={"lte": datetime_search["eq"]},
333+
properties__start_datetime={
334+
"lte": datetime_search["eq"]
335+
},
331336
),
332337
Q(
333338
"range",
@@ -362,11 +367,15 @@ def apply_datetime_filter(
362367
Q("exists", field="properties.end_datetime"),
363368
Q(
364369
"range",
365-
properties__start_datetime={"lte": datetime_search["lte"]},
370+
properties__start_datetime={
371+
"lte": datetime_search["lte"]
372+
},
366373
),
367374
Q(
368375
"range",
369-
properties__end_datetime={"gte": datetime_search["gte"]},
376+
properties__end_datetime={
377+
"gte": datetime_search["gte"]
378+
},
370379
),
371380
],
372381
),

0 commit comments

Comments
 (0)