Skip to content

Commit

Permalink
Don't try to bulk index empty body
Browse files Browse the repository at this point in the history
  • Loading branch information
andersju committed Sep 11, 2023
1 parent ffd08a6 commit e077b66
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions whelk-core/src/main/groovy/whelk/component/ElasticSearch.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,13 @@ class ElasticSearch {
}
}.join('')

String response = bulkClient.performRequest('POST', '/_bulk', bulkString, BULK_CONTENT_TYPE)
Map responseMap = mapper.readValue(response, Map)
log.info("Bulk indexed ${docs.count{it}} docs in ${responseMap.took} ms")
if (bulkString) {
String response = bulkClient.performRequest('POST', '/_bulk', bulkString, BULK_CONTENT_TYPE)
Map responseMap = mapper.readValue(response, Map)
log.info("Bulk indexed ${docs.count{it}} docs in ${responseMap.took} ms")
} else {
log.warn("Refused bulk indexing ${docs.count{it}} docs because body was empty")
}
}
}

Expand Down

0 comments on commit e077b66

Please sign in to comment.