Z User commited on
Commit
03bc913
·
1 Parent(s): 384f97f

fix(os): upsert_doc doc_id var + immediate refresh for single-doc writes

Browse files
Files changed (1) hide show
  1. app/stores/opensearch.py +6 -3
app/stores/opensearch.py CHANGED
@@ -129,14 +129,17 @@ class OpenSearchStore:
129
 
130
  async def index_doc(self, index: str, doc: dict, doc_id: Optional[str] = None) -> str:
131
  _id = doc_id or doc.get("account_id") or doc.get("contact_id") or doc.get("event_id") or doc.get("doc_id") or str(uuid.uuid4())
132
- res = await self.client().put(f"/{self._index(index)}/_doc/{_id}", json=doc)
 
 
 
133
  res.raise_for_status()
134
  return _id
135
 
136
  async def upsert_doc(self, index: str, doc: dict, doc_id: str) -> str:
137
  res = await self.client().put(
138
- f"/{self._index(index)}/_doc/{_id}", json=doc,
139
- params={"refresh": "false"},
140
  )
141
  res.raise_for_status()
142
  return doc_id
 
129
 
130
  async def index_doc(self, index: str, doc: dict, doc_id: Optional[str] = None) -> str:
131
  _id = doc_id or doc.get("account_id") or doc.get("contact_id") or doc.get("event_id") or doc.get("doc_id") or str(uuid.uuid4())
132
+ res = await self.client().put(
133
+ f"/{self._index(index)}/_doc/{_id}", json=doc,
134
+ params={"refresh": "true"},
135
+ )
136
  res.raise_for_status()
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=doc,
142
+ params={"refresh": "true"},
143
  )
144
  res.raise_for_status()
145
  return doc_id