Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
memoriav
Memobase 2020
services
Elasticsearch Services
Search Doc Service
Commits
e7c6049f
Commit
e7c6049f
authored
Jun 26, 2020
by
Jonas Waeber
Browse files
Fix json array extraction properly...
parent
151fb681
Pipeline
#10675
passed with stages
in 6 minutes and 19 seconds
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
src/main/kotlin/SearchDocTransform.kt
View file @
e7c6049f
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment