Skip to content

Conversation

@tloubrieu-jpl
Copy link
Contributor

@tloubrieu-jpl tloubrieu-jpl commented Dec 9, 2025

Related Issue(s):

Description:

Have opensearch datetime, geometry and collections fields defined as constant string so to be easily overwritten when the OpenSearch mapping requires it, as shown in example https://github.com/NASA-PDS/registry-stac-api/blob/464ce37952367fa845b325e36263b04a1fd89965/src/pds/registry/stac/database_logic.py#L28

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

@tloubrieu-jpl tloubrieu-jpl changed the title For other os schema Quick fix to help with alternate OpenSearch schemas Dec 9, 2025
@tloubrieu-jpl tloubrieu-jpl changed the title Quick fix to help with alternate OpenSearch schemas Quick and harmless fix to help with alternate OpenSearch schemas Dec 9, 2025
@jonhealy1 jonhealy1 self-requested a review December 9, 2025 15:22
Copy link
Collaborator

@jonhealy1 jonhealy1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @tloubrieu-jpl This looks really good. Can you add the same changes to the Elasticsearch backend. Thanks!

@tloubrieu-jpl
Copy link
Contributor Author

tloubrieu-jpl commented Dec 12, 2025

Hello @jonhealy1 ,

I made the extension to elasticsearch,

I also realized that I initially missed some strings, derived from the constants newly defined, in the nested field syntax of elasticsearch/opensearch. I made this fix with the latest commit.

I re-ran the tests (make test) as well and I noticed some errors (5) that I initially missed but sounds unrelated to te change of this PR.

Thanks

@jonhealy1
Copy link
Collaborator

Tests pass here! @tloubrieu-jpl Thanks for making the updates.

How would you feel about adding environment variables? This would make it a lot easier for developers to modify these fields.

PROPERTIES_DATETIME_FIELD = os.getenv("STAC_FIELD_PROP_DATETIME", "properties.datetime")
PROPERTIES_START_DATETIME_FIELD = os.getenv("STAC_FIELD_PROP_START_DATETIME", "properties.start_datetime")
PROPERTIES_END_DATETIME_FIELD = os.getenv("STAC_FIELD_PROP_END_DATETIME", "properties.end_datetime")
COLLECTION_FIELD = os.getenv("STAC_FIELD_COLLECTION", "collection")
GEOMETRY_FIELD = os.getenv("STAC_FIELD_GEOMETRY", "geometry")

@tloubrieu-jpl
Copy link
Contributor Author

Hi @jonhealy1 ,

I made the changes you proposed and updated the README with the new environment variables. That might be useful to other developers as the more of the OpenSearch/ElasticSearch index can be configured.
Note that in my case, I need anyhow to override the DatabaseLogic object for other purposes as well, so I can override the field's name value in the code of my derived class without using environment variable.

Thanks,

@jonhealy1 jonhealy1 self-requested a review December 15, 2025 06:09
Copy link
Collaborator

@jonhealy1 jonhealy1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tloubrieu-jpl Nice work - thanks for this.

@jonhealy1 jonhealy1 merged commit b8f2818 into stac-utils:main Dec 15, 2025
8 checks passed
@jonhealy1 jonhealy1 mentioned this pull request Dec 15, 2025
4 tasks
jonhealy1 added a commit that referenced this pull request Dec 15, 2025
**Related Issue(s):**

- None

**Description:**

#### Added

- Environment variable `VALIDATE_QUERYABLES` to enable/disable
validation of queryables in search/filter requests. When set to `true`,
search requests will be validated against the defined queryables,
returning an error for any unsupported fields. Defaults to `false` for
backward
compatibility.[#532](#532)
- Environment variable `QUERYABLES_CACHE_TTL` to configure the TTL (in
seconds) for caching queryables. Default is `1800` seconds (30 minutes)
to balance performance and freshness of queryables data.
[#532](#532)
- Added optional `/catalogs` route support to enable federated
hierarchical catalog browsing and navigation.
[#547](#547)
- Added DELETE `/catalogs/{catalog_id}/collections/{collection_id}`
endpoint to support removing collections from catalogs. When a
collection belongs to multiple catalogs, it removes only the specified
catalog from the collection's parent_ids. When a collection belongs to
only one catalog, the collection is deleted entirely.
[#554](#554)
- Added `parent_ids` internal field to collections to support
multi-catalog hierarchies. Collections can now belong to multiple
catalogs, with parent catalog IDs stored in this field for efficient
querying and management.
[#554](#554)
- Added GET `/catalogs/{catalog_id}/children` endpoint implementing the
STAC Children extension for efficient hierarchical catalog browsing.
Supports type filtering (?type=Catalog|Collection), pagination, and
returns numberReturned/numberMatched counts at the top level.
[#558](#558)
- Implemented context-aware dynamic linking: catalogs use dynamic
`rel="children"` links pointing to the `/catalogs/{id}/children`
endpoint, and collections have context-dependent `rel="parent"` links
(pointing to catalog when accessed via
`/catalogs/{id}/collections/{id}`, or root when accessed via
`/collections/{id}`). Catalog links are only injected in catalog
context. This eliminates race conditions and ensures consistency with
parent_ids relationships.
[#559](#559)

#### Changed

- Have opensearch datetime, geometry and collections fields defined as
constant strings
[#553](#553)

#### Fixed

- Fix unawaited coroutine in `stac_fastapi.core.core`.
[#551](#551)
- Parse `ES_TIMEOUT` environment variable as an integer.
[#556](#556)
- Implemented "Smart Unlink" logic in delete_catalog: when cascade=False
(default), collections are unlinked from the catalog and become
root-level orphans if they have no other parents, rather than being
deleted. When cascade=True, collections are deleted entirely. This
prevents accidental data loss and supports poly-hierarchy scenarios
where collections belong to multiple catalogs.
[#557](#557)
- Fixed delete_catalog to use reverse lookup query on parent_ids field
instead of fragile link parsing. This ensures all collections are found
and updated correctly, preventing ghost relationships where collections
remain tagged with deleted catalogs, especially in large catalogs or
pagination scenarios.
[#557](#557)


**PR Checklist:**

- [x] Code is formatted and linted (run `pre-commit run --all-files`)
- [x] Tests pass (run `make test`)
- [x] Documentation has been updated to reflect changes, if applicable
- [x] Changes are added to the changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants