query-26b7b4315b3d66f007d245e84a87f376

rq turtle/ttl

19:15, 10 September 2020 (UTC)) talk (Realworldobject : Before the filter is applied you have a result with each value of ?ignorableType for each ?item. The filter do remove results for each match with an ignorable type, but leaves result with unmatched ignorable type. If you know the number of ignorable types, you can count the results for each item and filter out ?item where some results are removed:Realworldobject@

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?typeLabel
WHERE {
  VALUES ?ignorableType {
    wd:Q5
    wd:Q20643955
  }

  VALUES ?item {
    wd:Q36322
  }

  ?item wdt:P31 ?type .

  FILTER NOT EXISTS {?item wdt:P31 ?ignorableType}

  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
GROUP BY ?item ?itemLabel ?typeLabel
HAVING (COUNT(?item) = 2) # 2 is the number of ignorable types.

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?_anon_d00291b7e9a143df8ec0be8c8ebd714c181") v3("?ignorableType") v3("?item"):::projected v3("?type") a1((" ")) c4(["bd:serviceParam"]):::iri c6(["#91;AUTO_LANGUAGE#93;,en"]):::literal f0[[" = '2^^xsd:integer'"]] f0 --> a1 f1[["not "]] subgraph f1e0["Exists Clause"] e0v1 --"wdt:P31"--> e0v2 e0v2("?ignorableType"):::projected e0v1("?item"):::projected end f1--EXISTS--> f1e0 f1 --> v3 f1 --> c2 f1 --> v3 v3 --"wdt:P31"--> v3 bind2[/VALUES ?ignorableType/] bind2-->v3 bind20(["wd:Q5"]) bind20 --> bind2 bind21(["wd:Q20643955"]) bind21 --> bind2 bind3[/VALUES ?item/] bind3-->v3 bind30(["wd:Q36322"]) bind30 --> bind3 v3 --"wdt:P31"--> v3 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c4 --"wikibase:language"--> c6 end bind5[/"count(?item)"/] v3 --o bind5 bind5 --as--o v4