diff --git a/whelk-core/src/main/groovy/whelk/search2/querytree/Condition.java b/whelk-core/src/main/groovy/whelk/search2/querytree/Condition.java index d551a22107..91674b5e9b 100644 --- a/whelk-core/src/main/groovy/whelk/search2/querytree/Condition.java +++ b/whelk-core/src/main/groovy/whelk/search2/querytree/Condition.java @@ -33,6 +33,7 @@ public sealed class Condition implements Node permits Type { private final Operator operator; private final Value value; + public Condition(Selector selector, Operator operator, Value value) { this.selector = selector; this.operator = operator; @@ -101,7 +102,9 @@ public boolean implies(Node node, JsonLd jsonLd) { @Override public RdfSubjectType rdfSubjectType() { - return RdfSubjectType.noType(); + return selector.domain().size() == 1 && selector instanceof Property p + ? p.domainTypes.getFirst().rdfSubjectType() + : RdfSubjectType.noType(); } @Override diff --git a/whelk-core/src/main/groovy/whelk/search2/querytree/Property.java b/whelk-core/src/main/groovy/whelk/search2/querytree/Property.java index 9a08069386..496701ab82 100644 --- a/whelk-core/src/main/groovy/whelk/search2/querytree/Property.java +++ b/whelk-core/src/main/groovy/whelk/search2/querytree/Property.java @@ -41,6 +41,7 @@ public non-sealed class Property extends PathElement { protected Map definition; protected List domain; + public List domainTypes; protected List range; protected String inverseOf; protected String langAlias; @@ -67,6 +68,7 @@ public Property(String name, JsonLd jsonLd) { protected Property(Map definition, JsonLd jsonLd) { this.definition = definition; this.domain = getDomain(jsonLd); + this.domainTypes = domain.stream().map(t -> new Type(t, jsonLd)).toList(); this.range = getRange(jsonLd); this.inverseOf = getInverseOf(jsonLd); this.indexKey = (String) definition.get("ls:indexKey"); // FIXME: This shouldn't have a different prefix (ls: vs librissearch:)