简体   繁体   English

限制本地 DBpedia SPARQL 查询的结果

[英]limiting results in local DBpedia SPARQL query

I am trying to get instances that contains keywords using bif:contains , but I want to get only one label for each ?s (instance) and I don't care which one.我正在尝试使用bif:contains获取包含关键字的实例,但我只想为每个?s (实例)获取一个标签,而我不在乎是哪一个。 I can't filter it with something like regex because it's for a general query.我不能用regex之类的东西过滤它,因为它是用于一般查询的。 This is my query but it gets all labels from each instance ( ?s ):这是我的查询,但它从每个实例( ?s )获取所有标签:

SELECT DISTINCT ?s,?o1,?sc,?l WHERE {
  ?s ?s1textp ?o1 .
  ?o1 bif:contains ' (madrid AND embargo) ' OPTION ( score ?sc ) . 
  ?s <http://www.w3.org/2000/01/rdf-schema#label> ?l      
}
ORDER BY DESC ( ?sc )
LIMIT 30
OFFSET 0

I tried out with nested queries, but when I add a LIMIT I get no results.我尝试使用嵌套查询,但是当我添加LIMIT我没有得到任何结果。

SELECT DISTINCT ?s,?o1,?sc,?l WHERE {
  ?s ?s1textp ?o1 .   
  ?o1 bif:contains ' (madrid AND embargo) ' OPTION ( score ?sc ) .                 
  {
    SELECT DISTINCT ?s,?l WHERE {
      ?s <http://www.w3.org/2000/01/rdf-schema#label> ?l
    }
    LIMIT 1
  }      
}
ORDER BY DESC ( ?sc )
LIMIT 30
OFFSET 0

I saw also the SAMPLE aggregate function;我还看到了SAMPLE聚合函数; it takes exactly what I want in DBpedia endpoint, but it's not working on my own Virtuoso!它完全符合我在 DBpedia 端点中想要的功能,但它不适用于我自己的 Virtuoso! (I'm using the open source version.) (我使用的是开源版本。)

SELECT DISTINCT ?s,?o1,?sc,?l WHERE {
  ?s ?s1textp ?o1 .
  ?o1 bif:contains ' (madrid AND embargo) ' OPTION ( score ?sc ) . 
  {
    SELECT DISTINCT ?s,(SAMPLE(?l) AS ?l) WHERE {
      ?s <http://www.w3.org/2000/01/rdf-schema#label> ?l
    }
    GROUP BY ?s
  }
}
ORDER BY desc ( ?sc )
LIMIT 30
OFFSET 0

The official DBpedia endpoint is running on Virtuoso, so if that's doing the right thing, you probably just need to update your own Virtuoso instance.官方 DBpedia 端点在 Virtuoso 上运行,因此如果这样做是正确的,您可能只需要更新自己的 Virtuoso 实例。 VOS is currently at 7.2.2 (or 6.1.8 , if you must stay on v6) 6.1.6 , and the Virtuoso Github space ( instructions ) holds the latest code cuts in stable/7 and develop/7 (and stable/6 and develop/6 ), each of which delivers what the path suggests. VOS 目前是7.2.2 (或6.1.8 ,如果你必须留在 v6) 6.1.6 ,Virtuoso Github 空间指令)保存了stable/7develop/7 (和stable/6develop/6 ),每个都提供路径建议的内容。

For the future -- questions specifically regarding Virtuoso are generally best raised on the public OpenLink Discussion Forums , the Virtuoso Users mailing list , or a confidential Support Case .对于未来——特别是关于 Virtuoso 的问题通常最好在公共 OpenLink 讨论论坛Virtuoso 用户邮件列表机密支持案例中提出

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM