如何在wikidata rdf Graph服务中使用OR

How to use OR in wikidata rdf Graph services

我以寻找元始汗的children为例。我怎样才能告诉图表走 P40 或 P10。我希望图表能够传输 2 种类型的 LinkType

#Children of Genghis Khan
#defaultView:Graph
PREFIX gas: <http://www.bigdata.com/rdf/gas#>

SELECT ?item ?itemLabel ?pic ?linkTo
WHERE {
  SERVICE gas:service {
    gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.SSSP" ;
                gas:in wd:Q720 ;
                gas:traversalDirection "Forward" ;
                gas:out ?item ;
                gas:out1 ?depth ;

                gas:maxIterations 4 ;
                gas:linkType wdt:P40.#Here, how can I do a OR operation
  }
  OPTIONAL { ?item wdt:P40 ?linkTo }
  OPTIONAL { ?item wdt:P18 ?pic }
  SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}

UNION 语句为您提供 OR 运算的效果,因此理论上复制和嵌套 P40 的当前 SERVICE 子句,并将其与 P10 的另一个子句组合,应该可以解决问题。例如:

#Children of Genghis Khan
#defaultView:Graph
PREFIX gas: <http://www.bigdata.com/rdf/gas#>

SELECT ?item ?itemLabel ?pic ?linkTo
WHERE {
  {
    SERVICE gas:service {
      gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.SSSP" ;
                  gas:in wd:Q720 ;
                  gas:traversalDirection "Forward" ;
                  gas:out ?item ;
                  gas:out1 ?depth ;
                  gas:maxIterations 4 ;
                  gas:linkType wdt:P40.
    }
    OPTIONAL { ?item wdt:P40 ?linkTo }
  } UNION {
    SERVICE gas:service {
      gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.SSSP" ;
                  gas:in wd:Q720 ;
                  gas:traversalDirection "Forward" ;
                  gas:out ?item ;
                  gas:out1 ?depth ;                  
                  gas:maxIterations 4 ;
                  gas:linkType wdt:P10.
    }
    OPTIONAL { ?item wdt:P10 ?linkTo }
  }
  OPTIONAL { ?item wdt:P18 ?pic }
  SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}