Commit e7c6049f authored by Jonas Waeber's avatar Jonas Waeber
Browse files

Fix json array extraction properly...

parent 151fb681
Pipeline #10675 passed with stages
in 6 minutes and 19 seconds
......@@ -102,14 +102,26 @@ class SearchDocTransform(mapping: String) {
Pair(targetField, value)
is JsonObject ->
Pair(targetField, mapOf(Pair(value["@language"], value["@value"])))
is JsonArray<*> ->
Pair(targetField, value.mapNotNull {
is JsonArray<*> -> {
val results = value.mapNotNull {
when (it) {
is String -> it
is JsonObject -> Pair(it["@language"], it["@value"])
else -> null
}
})
}
when {
results.isEmpty() -> {
null
}
results[0] is String -> {
Pair(targetField, results)
}
else -> {
Pair(targetField, (results as List<Pair<Any, Any>>).toMap())
}
}
}
else -> {
log.error("Could not parse literal value: $value.")
null
......
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