Spaces:
Sleeping
Sleeping
Z User commited on
Commit ·
1ec58c7
1
Parent(s): 03bc913
fix(os): strip OpenSearch metadata keys (_id/_score) before write-back
Browse files- app/stores/opensearch.py +4 -1
app/stores/opensearch.py
CHANGED
|
@@ -137,8 +137,11 @@ class OpenSearchStore:
|
|
| 137 |
return _id
|
| 138 |
|
| 139 |
async def upsert_doc(self, index: str, doc: dict, doc_id: str) -> str:
|
|
|
|
|
|
|
|
|
|
| 140 |
res = await self.client().put(
|
| 141 |
-
f"/{self._index(index)}/_doc/{doc_id}", json=
|
| 142 |
params={"refresh": "true"},
|
| 143 |
)
|
| 144 |
res.raise_for_status()
|
|
|
|
| 137 |
return _id
|
| 138 |
|
| 139 |
async def upsert_doc(self, index: str, doc: dict, doc_id: str) -> str:
|
| 140 |
+
# Docs read via get_doc carry OpenSearch metadata keys (_id/_score);
|
| 141 |
+
# writing them back is rejected as metadata fields.
|
| 142 |
+
clean = {k: v for k, v in doc.items() if not str(k).startswith("_")}
|
| 143 |
res = await self.client().put(
|
| 144 |
+
f"/{self._index(index)}/_doc/{doc_id}", json=clean,
|
| 145 |
params={"refresh": "true"},
|
| 146 |
)
|
| 147 |
res.raise_for_status()
|