Unverified Commit aa36f4da authored by Sebastian Schüpbach's avatar Sebastian Schüpbach
Browse files

use fully qualified id for api index

parent 2fce649c
Pipeline #46765 passed with stages
in 4 minutes and 12 seconds
......@@ -43,8 +43,8 @@ object App
else deleteInES(rec, esFrontendIndex)
)
.map(rec =>
if (rec.dryRun) existsInES(rec, esApiIndex)
else deleteInES(rec, esApiIndex)
if (rec.dryRun) existsInES(rec, esApiIndex, fullyQualifiedId = true)
else deleteInES(rec, esApiIndex, fullyQualifiedId = true)
)
.map(rec => deleteMariaDBEntries(rec))
.map(rec => deleteBinaries(rec))
......
......@@ -46,18 +46,19 @@ trait MemobaseElasticClient {
ElasticClient(JavaClient(props))
}
def existsInES(record: ProcessedRecord, esIndex: String): ProcessedRecord = {
def existsInES(record: ProcessedRecord, esIndex: String, fullyQualifiedId: Boolean = false): ProcessedRecord = {
val recordId = if (fullyQualifiedId) {s"https://memobase.ch/record/${record.recordId}"} else {record.recordId}
client
.execute {
logger.info(
s"Deleting ${record.recordId} in Elasticsearch index $esIndex"
s"Deleting $recordId in Elasticsearch index $esIndex"
)
exists(record.recordId, esIndex)
exists(recordId, esIndex)
}
.map {
case success: RequestSuccess[Boolean] if success.result =>
logger.debug(
s"Record ${record.recordId} exists in Elasticsearch index $esIndex"
s"Record $recordId exists in Elasticsearch index $esIndex"
)
record.setRecordStatus(
ProcessingSuccess,
......@@ -65,7 +66,7 @@ trait MemobaseElasticClient {
)
case _: RequestSuccess[_] =>
logger.debug(
s"Record ${record.recordId} does not exist in Elasticsearch index $esIndex"
s"Record $recordId does not exist in Elasticsearch index $esIndex"
)
record.setRecordStatus(
ProcessingIgnore,
......@@ -74,7 +75,7 @@ trait MemobaseElasticClient {
case failure: RequestFailure =>
logger.warn(
s"Check of existence for record ${record.recordId} in Elasticsearch index $esIndex failed: ${failure.error.reason}"
s"Check of existence for record $recordId in Elasticsearch index $esIndex failed: ${failure.error.reason}"
)
record.setRecordStatus(
ProcessingFatal,
......@@ -84,19 +85,20 @@ trait MemobaseElasticClient {
.await
}
def deleteInES(record: ProcessedRecord, esIndex: String): ProcessedRecord = {
def deleteInES(record: ProcessedRecord, esIndex: String, fullyQualifiedId: Boolean = false): ProcessedRecord = {
val recordId = if (fullyQualifiedId) {s"https://memobase.ch/record/${record.recordId}"} else {record.recordId}
client
.execute {
logger.info(
s"Deleting ${record.recordId} in Elasticsearch index $esIndex${if (record.dryRun) " (dry-run mode)"
s"Deleting $recordId in Elasticsearch index $esIndex${if (record.dryRun) " (dry-run mode)"
else ""}"
)
deleteById(esIndex, record.recordId)
deleteById(esIndex, recordId)
}
.map {
case success: RequestSuccess[_] if success.status < 400 =>
logger.debug(
s"Deletion of record ${record.recordId} in Elasticsearch index $esIndex successful${if (record.dryRun) " (dry-run mode)"
s"Deletion of record $recordId in Elasticsearch index $esIndex successful${if (record.dryRun) " (dry-run mode)"
else ""}"
)
record.setRecordStatus(
......@@ -105,7 +107,7 @@ trait MemobaseElasticClient {
)
case _: RequestSuccess[_] =>
logger.debug(
s"Deletion of record ${record.recordId} in Elasticsearch index $esIndex failed since record does not exist${if (record.dryRun) " (dry-run mode)" else ""}"
s"Deletion of record $recordId in Elasticsearch index $esIndex failed since record does not exist${if (record.dryRun) " (dry-run mode)" else ""}"
)
record.setRecordStatus(
ProcessingIgnore,
......@@ -114,7 +116,7 @@ trait MemobaseElasticClient {
case failure: RequestFailure =>
logger.warn(
s"Deletion of record ${record.recordId} in Elasticsearch index $esIndex failed${if (record.dryRun) " (dry-run mode)"
s"Deletion of record $recordId in Elasticsearch index $esIndex failed${if (record.dryRun) " (dry-run mode)"
else ""}: ${failure.error.reason}"
)
record.setRecordStatus(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment