Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
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
56bc317a
Commit
56bc317a
authored
Jul 29, 2021
by
Jonas Waeber
Browse files
Documents can now properly get the full institution name list from the record set index.
parent
56338a33
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/kotlin/ch/memobase/DocumentsSearchDocBuilder.kt
View file @
56bc317a
...
@@ -247,7 +247,7 @@ class DocumentsSearchDocBuilder(
...
@@ -247,7 +247,7 @@ class DocumentsSearchDocBuilder(
sameAs
=
Extract
.
listOfStrings
(
record
[
"sameAs"
]),
sameAs
=
Extract
.
listOfStrings
(
record
[
"sameAs"
]),
abstract
=
Extract
.
languageContainer
(
"abstract (record id: $key)"
,
record
[
"abstract"
]),
abstract
=
Extract
.
languageContainer
(
"abstract (record id: $key)"
,
record
[
"abstract"
]),
recordId
=
key
,
recordId
=
key
,
institution
=
extractInstitution
(
record
).
map
{
value
->
elasticSearchWrapper
.
getInstitutionName
(
value
)
}
,
institution
=
elasticSearchWrapper
.
getInstitutionName
sFromRecordSet
(
recordSetId
)
,
recordSet
=
FacetContainer
(
recordSet
=
FacetContainer
(
elasticSearchWrapper
.
getRecordSetName
(
recordSetId
),
elasticSearchWrapper
.
getRecordSetName
(
recordSetId
),
null
,
null
,
...
...
src/main/kotlin/ch/memobase/helpers/ElasticSearchWrapper.kt
View file @
56bc317a
...
@@ -160,6 +160,61 @@ class ElasticSearchWrapper(
...
@@ -160,6 +160,61 @@ class ElasticSearchWrapper(
}
}
}
}
/***
* This function exists because some record sets are managed by multiple institutions. However, the document itself
* always assumes that there is only one. As a result the institution names must be retrieved from the
* record set in that case.
*/
fun
getInstitutionNamesFromRecordSet
(
recordSetIdentifier
:
String
):
List
<
FacetContainer
>
{
return
try
{
log
.
debug
(
"Attempting to retrieve record set document."
)
val
request
=
GetRequest
(
recordSetIndex
,
recordSetIdentifier
)
val
response
=
client
.
get
(
request
,
RequestOptions
.
DEFAULT
)
if
(
response
.
isExists
)
{
val
map
=
response
.
sourceAsMap
[
"institution"
]
if
(
map
==
null
)
{
log
.
error
(
"Found record set for id $recordSetIdentifier in "
+
"index $recordSetIndex, but could not extract name."
)
listOf
(
FacetContainer
(
LanguageContainer
.
EMPTY
,
recordSetIdentifier
,
emptyList
()
))
}
else
{
log
.
info
(
"Retrieval of institution names was successful."
)
when
(
map
)
{
is
List
<
*
>
->
{
map
.
map
{
FacetContainer
.
fromMap
(
it
)
}
}
is
Map
<
*
,
*
>
->
{
listOf
(
FacetContainer
.
fromMap
(
map
))
}
else
->
{
log
.
error
(
"The retrieved data is not valid: $map."
)
listOf
(
FacetContainer
.
EMPTY
)
}
}
}
}
else
{
log
.
error
(
"Could not find record set id $recordSetIdentifier in index $recordSetIndex."
)
listOf
(
FacetContainer
(
LanguageContainer
.
EMPTY
,
recordSetIdentifier
,
emptyList
()
))
}
}
catch
(
ex
:
ElasticsearchException
)
{
log
.
error
(
ex
.
detailedMessage
)
listOf
(
FacetContainer
(
LanguageContainer
.
EMPTY
,
recordSetIdentifier
,
emptyList
()
))
}
}
fun
getInstitutionName
(
identifier
:
String
):
FacetContainer
{
fun
getInstitutionName
(
identifier
:
String
):
FacetContainer
{
return
try
{
return
try
{
log
.
debug
(
"Attempting to retrieve institution record."
)
log
.
debug
(
"Attempting to retrieve institution record."
)
...
...
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