stac-utils / stac-fastapi-elasticsearch-opensearch

Elasticsearch backend for stac-fastapi with Opensearch support.
https://stac-utils.github.io/stac-fastapi-elasticsearch-opensearch
MIT License
24 stars 14 forks source link

Links returned by search queries don't contain custom fields #247

Open pedro-cf opened 1 month ago

pedro-cf commented 1 month ago

Describe the bug Links returned by search queries don't contain custom fields.

To Reproduce

  1. Run app docker-compose up
  2. Create test collection
    curl --request POST \
    --url http://localhost:8080/collections \
    --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
    --header 'Content-Type: application/json' \
    --data '{"id":"test-collection","stac_extensions":["https://stac-extensions.github.io/eo/v1.0.0/schema.json"],"type":"Collection","description":"Landat 8 imagery radiometrically calibrated and orthorectified using gound points and Digital Elevation Model (DEM) data to correct relief displacement.","stac_version":"1.0.0","summaries":{"platform":["landsat-8"],"instruments":["oli","tirs"],"gsd":[30]},"extent":{"spatial":{"bbox":[[-180,-90,180,90]]},"temporal":{"interval":[["2013-06-01",null]]}},"links":[{"href":"http://localhost:8081/collections/landsat-8-l1","rel":"self","type":"application/json"},{"href":"http://localhost:8081/","rel":"parent","type":"application/json"},{"href":"http://localhost:8081/collections/landsat-8-l1/items","rel":"item","type":"application/geo+json"},{"href":"http://localhost:8081/","rel":"root","type":"application/json"}],"title":"Landsat 8 L1","keywords":["landsat","earth observation","usgs"]}'
  3. Create item with custom links (example from https://github.com/stac-extensions/web-map-links):
    curl --request POST \
    --url http://localhost:8080/collections/test-collection/items \
    --header 'Content-Type: application/json' \
    --data '{"stac_version":"1.0.0","collection":"test-collection","stac_extensions":["https://stac-extensions.github.io/web-map-links/v1.2.0/schema.json"],"type":"Feature","id":"item","bbox":[172.9,1.3,173,1.4],"geometry":{"type":"Polygon","coordinates":[[[172.9,1.3],[173,1.3],[173,1.4],[172.9,1.4],[172.9,1.3]]]},"properties":{"datetime":"2020-12-11T22:38:32Z"},"attribution":"© 2022 The Example Corp.","links":[{"href":"https://example.com/examples/item.json","rel":"self"},{"href":"https://maps.example.com/wmts","rel":"wmts","type":"image/png","title":"RGB composite visualized through a WMTS","wmts:layer":["streets","satellite"]},{"href":"https://maps.example.com/wms","rel":"wms","type":"image/png","title":"RGB composite visualized through a WMS","wms:layers":["rgb"],"wms:transparent":true},{"href":"https://maps.example.com/xyz/{z}/{x}/{y}.jpg","rel":"xyz","type":"image/jpeg","title":"RGB composite visualized through a XYZ"},{"href":"https://maps.example.com/item/tilejson.json","rel":"tilejson","title":"TileJSON","type":"application/json"},{"href":"https://storage.googleapis.com/open-cogs/planet-stac/cocabamba-peru/3d-geofox.ai/3DTiles/tileset.json","rel":"3d-tiles","title":"3D Tiles","type":"application/json"},{"href":"https://maps.example.com/item/example.pmtiles","rel":"pmtiles","title":"PMTiles","type":"application/vnd.pmtiles","pmtiles:layers":["streets"]}],"assets":{}}'
  4. Search for all items:
    curl --request POST \
    --url http://localhost:8080/search \
    --header 'Content-Type: application/json' \
    --data '{}'
  5. Response will will include links as follows:
    "links": [
    {
    "href": "https://maps.example.com/wms",
    "rel": "wms",
    "type": "image/png",
    "title": "RGB composite visualized through a WMS"
    }

Expected behavior Web Map Links should include custom fields like:

{
      "href": "https://maps.example.com/wms",
      "rel": "wms",
      "type": "image/png",
      "title": "RGB composite visualized through a WMS",
      "wms:layers": [
        "rgb"
      ],
      "wms:transparent": true
}

Additional context https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/blob/c5c96c91d576edd7de3187c17b4edc5ec62e85cb/stac_fastapi/core/stac_fastapi/core/core.py#L606

Issue seems to be the version of stac_pydantic==2.0.*, I believe this will be fixed if upgraded to stac_pydantic==3.0.0 with stac-fastapi.api==3.0.0

jonhealy1 commented 1 month ago

This may be fixed in the new version of stac-fastapi - 3.0 - but let's write a test for this before we close the issue.

jonhealy1 commented 1 month ago

This is not working as of #234. This should work according to the item spec: https://schemas.stacspec.org/v1.0.0/item-spec/json-schema/item.json. I think we should start an issue in stac-pydantic.