我正在编写一些在 jena 和 sesame2 上运行的查询。它们中的大多数在 sesame2 下都可以正常工作,除非我指定了路径的深度。例如,如果我在 sesame 下运行此查询,它会给出 8 个结果,而 jena 会给出 217(正确的数字)。
PREFIX edge: <http://danielfrentz.com/edge#>
PREFIX property: <http://danielfrentz.com/property#>
select distinct ?start ?reached where{
?start property:id \"v1\".
?start (edge:uses | edge:implements | edge:extends)+ ?reached.
filter(?start != ?reached)}
所以我的问题是,sesame2 对路径深度语法的定义是否不同?还是有其他原因导致我可能会得到不同的结果?
谢谢。
额外细节:
我正在使用 2.6.10 并试用 2.7 beta。
我拥有的最小示例图如下(对不起,太长了):
@prefix edge: <http://danielfrentz.com/edge#>.
@prefix edge: <http://danielfrentz.com/property#>.
<http://danielfrentz.com/v2> <http://danielfrentz.com/property#name> "Class3".
<http://danielfrentz.com/v2> <http://danielfrentz.com/property#abstract> "false".
<http://danielfrentz.com/v2> <http://danielfrentz.com/property#type> "class".
<http://danielfrentz.com/v2> <http://danielfrentz.com/property#namespace> "com.example".
<http://danielfrentz.com/v2> <http://danielfrentz.com/property#id> "v2".
<http://danielfrentz.com/v1> <http://danielfrentz.com/property#name> "Class2".
<http://danielfrentz.com/v1> <http://danielfrentz.com/property#abstract> "false".
<http://danielfrentz.com/v1> <http://danielfrentz.com/property#type> "class".
<http://danielfrentz.com/v1> <http://danielfrentz.com/property#namespace> "com.example".
<http://danielfrentz.com/v1> <http://danielfrentz.com/property#id> "v1".
<http://danielfrentz.com/v3> <http://danielfrentz.com/property#name> "Class4".
<http://danielfrentz.com/v3> <http://danielfrentz.com/property#abstract> "false".
<http://danielfrentz.com/v3> <http://danielfrentz.com/property#type> "class".
<http://danielfrentz.com/v3> <http://danielfrentz.com/property#namespace> "com.example".
<http://danielfrentz.com/v3> <http://danielfrentz.com/property#id> "v3".
<http://danielfrentz.com/v4> <http://danielfrentz.com/property#name> "AbstractClass1".
<http://danielfrentz.com/v4> <http://danielfrentz.com/property#abstract> "true".
<http://danielfrentz.com/v4> <http://danielfrentz.com/property#type> "class".
<http://danielfrentz.com/v4> <http://danielfrentz.com/property#namespace> "com.example".
<http://danielfrentz.com/v4> <http://danielfrentz.com/property#id> "v4".
<http://danielfrentz.com/v0> <http://danielfrentz.com/property#name> "Class1".
<http://danielfrentz.com/v0> <http://danielfrentz.com/property#abstract> "false".
<http://danielfrentz.com/v0> <http://danielfrentz.com/property#type> "class".
<http://danielfrentz.com/v0> <http://danielfrentz.com/property#namespace> "com.example".
<http://danielfrentz.com/v0> <http://danielfrentz.com/property#id> "v0".
<http://danielfrentz.com/v5> <http://danielfrentz.com/property#name> "Interface1".
<http://danielfrentz.com/v5> <http://danielfrentz.com/property#abstract> "true".
<http://danielfrentz.com/v5> <http://danielfrentz.com/property#type> "interface".
<http://danielfrentz.com/v5> <http://danielfrentz.com/property#namespace> "com.example".
<http://danielfrentz.com/v5> <http://danielfrentz.com/property#id> "v5".
<http://danielfrentz.com/v3> <http://danielfrentz.com/edge#extends> <http://danielfrentz.com/v4>.
<http://danielfrentz.com/v2> <http://danielfrentz.com/edge#uses> <http://danielfrentz.com/v3>.
<http://danielfrentz.com/v4> <http://danielfrentz.com/edge#uses> <http://danielfrentz.com/v2>.
<http://danielfrentz.com/v5> <http://danielfrentz.com/edge#uses> <http://danielfrentz.com/v0>.
<http://danielfrentz.com/v1> <http://danielfrentz.com/edge#implements> <http://danielfrentz.com/v5>.
<http://danielfrentz.com/v0> <http://danielfrentz.com/edge#uses> <http://danielfrentz.com/v1>.
查询是:
PREFIX edge: <http://danielfrentz.com/edge#>
PREFIX property: <http://danielfrentz.com/property#>
select distinct ?start ?reached where{
?start property:id \"v1\".
?start (edge:uses | edge:implements | edge:extends){1,3} ?reached.
FILTER (?start != ?reached)}
结果是:
start start=http://danielfrentz.com/v1
reached reached=http://danielfrentz.com/v5
应该有 2 个结果而不是 1 个。
我还应该补充一点,当我不使用属性路径(即我使用 + 而不是 {1,3})时,它会给出正确数量的结果。