From 1a22d4c7e3eba42803ba3d0946bfa2ba02fe6f1c Mon Sep 17 00:00:00 2001 From: jonhealy1 Date: Mon, 5 May 2025 15:29:47 +0800 Subject: [PATCH] update item method fix --- CHANGELOG.md | 1 + stac_fastapi/core/stac_fastapi/core/core.py | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18191082..3061b134 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Updated dynamic mapping for items to map long values to double versus float [#326](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/326) - Extended Datetime Search to search on start_datetime and end_datetime as well as datetime fields. [#182](https://github.com/stac-utils/stac-fastapi-elasticsearch/pull/182) +- Changed item update operation to use Elasticsearch index API instead of delete and create for better efficiency and atomicity. [#75](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/issues/75) ### Fixed diff --git a/stac_fastapi/core/stac_fastapi/core/core.py b/stac_fastapi/core/stac_fastapi/core/core.py index d9e8d214..5ddbb7d9 100644 --- a/stac_fastapi/core/stac_fastapi/core/core.py +++ b/stac_fastapi/core/stac_fastapi/core/core.py @@ -742,8 +742,7 @@ async def update_item( item["properties"]["updated"] = now await self.database.check_collection_exists(collection_id) - await self.delete_item(item_id=item_id, collection_id=collection_id) - await self.create_item(collection_id=collection_id, item=Item(**item), **kwargs) + await self.database.create_item(item, refresh=kwargs.get("refresh", False)) return ItemSerializer.db_to_stac(item, base_url)