Skip to content

Commit 0ee60e2

Browse files
authored
Fixed end_datetime selection when splitting indices in a datetime-based indexing strategy. (#595)
A fix to my previous MR(#537) related to indices based on datetime / start_datetime / end_datetime. During a rebase, one line was changed. Additionally, I’m adding a fallback and logging for index selection. PR Checklist: - [ ] Code is formatted and linted (run `pre-commit run --all-files`) - [ ] Tests pass (run `make test`) - [ ] Documentation has been updated to reflect changes, if applicable - [ ] Changes are added to the changelog
1 parent c81fa6b commit 0ee60e2

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1414
### Fixed
1515

1616
- Fixed bulk_sync_prep_create_item to properly detect duplicates across indexes. [#575](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/575)
17+
- Fixed end_datetime selection when splitting indices in a datetime-based indexing strategy. [#591](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/591)
1718

1819
### Removed
1920

stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/database/index.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ def check_criteria(
165165
datetime_alias if use_datetime else start_datetime_alias
166166
)
167167

168-
filtered_indexes.append(primary_datetime_alias)
168+
if primary_datetime_alias is not None:
169+
filtered_indexes.append(primary_datetime_alias)
169170

170171
return filtered_indexes
171172

stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/search_engine/inserters.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,10 @@ async def _get_target_index_internal(
257257
extract_date(latest_item["_source"]["properties"]["datetime"])
258258
),
259259
end_datetime=str(
260-
extract_date(latest_item["_source"]["properties"]["end_datetime"])
261-
),
260+
extract_first_date_from_index(aliases_dict["end_datetime"])
261+
)
262+
if aliases_dict.get("end_datetime")
263+
else None,
262264
)
263265

264266
await self.datetime_manager.handle_oversized_index(

stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/search_engine/selection/selectors.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
"""Async index selectors with datetime-based filtering."""
2-
32
from typing import Any, Dict, List, Optional, Tuple
43

54
from stac_fastapi.core.utilities import get_bool_env

0 commit comments

Comments
 (0)