Fix document missing exception for ES/OS update entity (#24562)

This commit is contained in:
Bhanu Agrawal 2025-11-28 16:36:21 +05:30 committed by GitHub
parent 8ad2760d11
commit fccd717fbd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 2 deletions

View File

@ -361,6 +361,7 @@ public class ElasticSearchEntityManager implements EntityManagementClient {
.id(docId)
.refresh(Refresh.True)
.scriptedUpsert(true)
.upsert(params)
.script(
s ->
s.inline(
@ -375,7 +376,20 @@ public class ElasticSearchEntityManager implements EntityManagementClient {
"Successfully updated entity in ElasticSearch for index: {}, docId: {}",
indexName,
docId);
} catch (IOException | ElasticsearchException e) {
} catch (ElasticsearchException e) {
if (e.status() == 404) {
LOG.warn(
"Document not found during update for index: {}, docId: {}. The document may not have been indexed yet.",
indexName,
docId);
} else {
LOG.error(
"Failed to update entity in ElasticSearch for index: {}, docId: {}",
indexName,
docId,
e);
}
} catch (IOException e) {
LOG.error(
"Failed to update entity in ElasticSearch for index: {}, docId: {}", indexName, docId, e);
}

View File

@ -369,6 +369,7 @@ public class OpenSearchEntityManager implements EntityManagementClient {
.id(docId)
.refresh(Refresh.True)
.scriptedUpsert(true)
.upsert(params)
.script(
s ->
s.inline(
@ -381,7 +382,17 @@ public class OpenSearchEntityManager implements EntityManagementClient {
LOG.info(
"Successfully updated entity in OpenSearch for index: {}, docId: {}", indexName, docId);
} catch (IOException | OpenSearchException e) {
} catch (OpenSearchException e) {
if (e.status() == 404) {
LOG.warn(
"Document not found during update for index: {}, docId: {}. The document may not have been indexed yet.",
indexName,
docId);
} else {
LOG.error(
"Failed to update entity in OpenSearch for index: {}, docId: {}", indexName, docId, e);
}
} catch (IOException e) {
LOG.error(
"Failed to update entity in OpenSearch for index: {}, docId: {}", indexName, docId, e);
}