Skip to content

Commit b44315f

Browse files
imsduSimon Dumas
andauthored
Fix search query when subject age is repeated (#5178)
Co-authored-by: Simon Dumas <simon.dumas@epfl.ch>
1 parent 2895766 commit b44315f

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

tests/docker/config/search/construct-query.sparql

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -511,19 +511,21 @@ CONSTRUCT {
511511

512512
# Subject
513513
OPTIONAL {
514-
?id nsg:subject / nsg:age ?age .
515-
OPTIONAL { ?age schema:value ?subjectAgeValue . } .
516-
OPTIONAL { ?age schema:minValue ?subjectAgeMinValue . } .
517-
OPTIONAL { ?age schema:maxValue ?subjectAgeMaxValue . } .
518-
?age schema:unitCode ?subjectAgeUnit .
519-
?age nsg:period ?subjectAgePeriod .
520-
BIND(
521-
IF(
522-
BOUND(?subjectAgeValue),
523-
CONCAT(STR(?subjectAgeValue), " ", STR(?subjectAgeUnit), " ", STR(?subjectAgePeriod)),
524-
CONCAT(STR(?subjectAgeMinValue), " to ", STR(?subjectAgeMaxValue), " ", STR(?subjectAgeUnit), " ", STR(?subjectAgePeriod))
525-
) as ?subjectAgeLabel ) .
526-
} .
514+
GRAPH ?id {
515+
BIND(BNODE(CONCAT(STR(?id), '/age')) as ?age ) .
516+
OPTIONAL { ?id nsg:subject / nsg:age / schema:value ?subjectAgeValue . } .
517+
OPTIONAL { ?id nsg:subject / nsg:age / schema:minValue ?subjectAgeMinValue . } .
518+
OPTIONAL { ?id nsg:subject / nsg:age / schema:maxValue ?subjectAgeMaxValue . } .
519+
?id nsg:subject / nsg:age / schema:unitCode ?subjectAgeUnit .
520+
?id nsg:subject / nsg:age / nsg:period ?subjectAgePeriod .
521+
BIND(
522+
IF(
523+
BOUND(?subjectAgeValue),
524+
CONCAT(STR(?subjectAgeValue), " ", STR(?subjectAgeUnit), " ", STR(?subjectAgePeriod)),
525+
CONCAT(STR(?subjectAgeMinValue), " to ", STR(?subjectAgeMaxValue), " ", STR(?subjectAgeUnit), " ", STR(?subjectAgePeriod))
526+
) as ?subjectAgeLabel ) .
527+
}
528+
} .
527529

528530
OPTIONAL {
529531
?id nsg:subject / schema:weight ?weight .

0 commit comments

Comments
 (0)