Skip to content

Conversation

@bountx
Copy link
Collaborator

@bountx bountx commented Dec 2, 2025

Related Issue(s):

Description:

Adds configuration-based support for extending Elasticsearch/OpenSearch index mappings via environment variables, allowing users to customize field mappings without code changes.

Features:

  • STAC_FASTAPI_ES_CUSTOM_MAPPINGS - JSON string to inject custom field mappings (e.g., for SAR, datacube extensions, or performance optimizations)
  • STAC_FASTAPI_ES_DYNAMIC_MAPPING - Control dynamic field mapping behavior (true/false/strict)

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

@bountx
Copy link
Collaborator Author

bountx commented Dec 4, 2025

Hi, @jonhealy1 - this PR is ready for CR :)

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.

Very good work here. This is a great addition! Custom mappings are definitely needed.

However, I find that passing large, complex JSON blobs via environment variables (STAC_FASTAPI_ES_CUSTOM_MAPPINGS) can be quite awkward and error-prone in deployment scenarios (escaping quotes, line limits, etc.).

Could we please add support for a file-based alternative?

For example, introduce a STAC_FASTAPI_ES_MAPPINGS_FILE environment variable.

If STAC_FASTAPI_ES_MAPPINGS_FILE is set, the application reads the JSON content from that file path.

We can keep STAC_FASTAPI_ES_CUSTOM_MAPPINGS for quick overrides.

This would allow users to simply mount a mappings.json file (e.g., via a Kubernetes ConfigMap) which is a much cleaner operational pattern.

@bountx
Copy link
Collaborator Author

bountx commented Dec 8, 2025

Thanks! In hindsight I agree that mappings need the file-based alternative. I'll also leave current variable for quick overrides.

So priority in what actually gets to set the mapping is:
quick override > file-based mapping > default mapping

@bountx
Copy link
Collaborator Author

bountx commented Dec 8, 2025

Hey @jonhealy1, I've implemented the requested changes

@bountx bountx requested a review from jonhealy1 December 8, 2025 09:42
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.

Super cool thanks @bountx

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.

3 participants