Skip to content

Commit

Permalink
More ES robustness
Browse files Browse the repository at this point in the history
  • Loading branch information
akariv committed Feb 5, 2025
1 parent 6f4d88b commit 6ce70e9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion odds/backend/scanner/worldbank/worldbank_catalog_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ async def scan(self) -> AsyncIterator[Dataset]:
description='\n'.join(filter(None, [identification.get('title'), identification.get('subtitle'), identification.get('description')])),
publisher=identification.get('citation'),
publisher_description='',
resources=resources
resources=resources,
link=f'https://datacatalog.worldbank.org/search/dataset/{dataset_unique_id}'
)
yield dataset
5 changes: 4 additions & 1 deletion odds/common/qa_repo/es/es_qa_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ async def storeQA(self, question: str, answer: str, success: bool, score: int, d
deployment_id=deployment_id,
embeddings=(await embedder.embed(question)).tolist()
)
await client.create(index=ES_INDEX, id=id, body=body)
try:
await client.create(index=ES_INDEX, id=id, body=body)
except elasticsearch.ConflictError:
await client.update(index=ES_INDEX, id=id, body={'doc': body})
return self.toQa(body)

async def getQuestion(self, *, question: str=None, id: str=None, deployment_id: str=None) -> Optional[QA]:
Expand Down

0 comments on commit 6ce70e9

Please sign in to comment.