Skip to content

Commit

Permalink
Add ES fails to .err[] during indexing (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
hayco authored May 24, 2024
1 parent 55713bb commit 295f1bd
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,11 @@ class BrintaResource(
val fetchedSegments = fetchTextSegmentsLocal(textLines, textURL)
if (fetchedSegments.isNotEmpty()) {
payload["text"] = fetchedSegments.joinToString(joinSeparator)
ok.add(docId)
} else {
logger.atWarn().log("Failed to fetch text for {} from {}", docId, textURL)
err.add(
mapOf(
"body.id" to docId,
"bodyId" to docId,
"annoURL" to anno.read("$.id"),
"textURL" to textURL
)
Expand Down Expand Up @@ -237,11 +236,18 @@ class BrintaResource(
if (statusInfo.family != Response.Status.Family.SUCCESSFUL) { // could be OK or CREATED
val entity = readEntityAsJsonString() // !! must read entity to close connection!
logger.atWarn().log("Failed to index {}: {}", docId, entity)
err.add(
mapOf(
"bodyId" to docId,
"annoURL" to anno.read("$.id"),
"elastic" to entity
)
)
} else {
close() // explicit close, or connection pool will be exhausted !!!
ok.add(docId)
}
}

}
}

Expand Down

0 comments on commit 295f1bd

Please sign in to comment.