【问题标题】:SPARQL Query with filtering over an integer对整数进行过滤的 SPARQL 查询
【发布时间】:2015-02-19 14:45:23
【问题描述】:

我正在编写一个非常简单的 sparql 查询来过滤整数值。

我通过this tutorial知道了 我知道 Wikipedia Id = 856 是针对 apple_inc 的,但是这个查询没有给出任何结果,我不知道我错过了什么。任何帮助将不胜感激。

select ?uri where {?uri <http://dbpedia.org/ontology/wikiPageID> ?id. FILTER regex(?id, "856"^^xsd:integer, "i")}

【问题讨论】:

  • regex 不允许在第二个参数中使用数字 => 类型错误 =>filter false。

标签: sparql wikipedia-api


【解决方案1】:

这里根本没有理由使用过滤器。从概念上讲,过滤器必须选择所有的页面 id 三元组,然后过滤掉除正确的三元组之外的所有页面。 (不过,实现应该使流程更高效。)

将值直接放在查询中并完全跳过过滤器会更清楚:

select ?uri where {
  ?uri <http://dbpedia.org/ontology/wikiPageID> 856
} 

【讨论】:

    【解决方案2】:

    你应该这样写:

    select ?uri where {?uri <http://dbpedia.org/ontology/wikiPageID> ?id. FILTER (?id=856)}
    

    【讨论】:

    • 从概念上讲,这必须选择 all 页面 id 三元组,然后过滤掉除正确的之外的所有。 (虽然实现应该使过程更高效。)将值放在查询中并完全跳过过滤器会更清楚:select ?uri where {?uri &lt;http://dbpedia.org/ontology/wikiPageID&gt; 856 .}
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多