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

Are item IDs intended to be unique across all collections? #261

Closed pedro-cf closed 1 month ago

pedro-cf commented 1 month ago

Describe the bug Currently item ID's are required to be unique across all collections. (Not sure if bug or not)

To Reproduce Steps to reproduce the behavior:

  1. Run instance docker-compose up
  2. Create collection with id collection1
  3. Create collection with id collection2
  4. Create item with id item1 in collection collection1
  5. Create item with id item1 in collection collection2
  6. See error:
    {
    "code": "ConflictError",
    "description": "Item item1 in collection collection1 already exists"
    }

Expected behavior Unsure.

Screenshots image

StijnCaerts commented 1 month ago

I think this should not happen, item IDs should only be unique within the collection. Not sure how you got this error, it seems like it is covered in the database logic: https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/blob/49fecf95a986ea5cca60af60d6b16a194cd23439/stac_fastapi/opensearch/stac_fastapi/opensearch/database_logic.py#L692-L695

Or does the Item contain the collection ID? It might be possible to POST an Item where the collection in the HTTP request does not match the collection specified in the Item body. https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/blob/49fecf95a986ea5cca60af60d6b16a194cd23439/stac_fastapi/core/stac_fastapi/core/core.py#L684

pedro-cf commented 1 month ago

Or does the Item contain the collection ID

You are right, my mistake...

Although this doesn't seem very logical, the collection id shouldn't be passed in the item body at all in my opinion since we already specify the collection id in the request URL:

POST http://localhost:8080/collections/{collection_id}/items