我正在尝试在 Jena Sparql 的过滤器中应用子查询。这可能吗。如果是,如何?例如:
SELECT ?x WHERE(?y <xyz:> ?z . ?y <abc:> ?x .FILTER regex(?z,subquery,"i")}
我的意思是我想在 jena 中使用一些子查询在过滤器中给出表达式。我该怎么做?如果不是,它的替代品是什么?
您不能将子查询放在过滤器表达式中,因为子查询不是具有值的表达式。不过,您可以使用子查询来提供您在过滤器表达式中使用的值。例如,
# Find persons whose names are also the names of flowers (Rose, Daisy, etc.) by
# performing a subquery to find all the flower names, and then finding people
# whose names match those names.
select ?person where {
?person a :Person ;
:name ?name .
filter regex(?name,?flowerName, "i" )
{ select ?flowerName { ?flower a :Flower ; :name ?flowerName } }
}