0

I like to query out all people who is connected to each other but filter by qualifier value of the path

For example, the query below will get all human related to Putin. But his spouse, whose in statement get the qualifier "endtime" should not be followed

PREFIX  rdfs:  <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?pep ?pepLabel ?relation ?relationLabel ?relatedPerson ?relatedPersonLabel ?endtimequalifier
WHERE 
{
VALUES ?pep {wd:Q7747}  
?relatedPerson wdt:P31 wd:Q5.
?pep ?relation ?relatedPerson.
#What should I put here for the query to ignore the spouse since the endtimequalifier is available
  OPTIONAL{
  ?pep p:P26 [ps:P26 ?spouse; pq:P582 ?endtimequalifier ].
  }

SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }

}
Loredra L
  • 1,485
  • 2
  • 16
  • 32
  • not sure if I understand, but absence of data is done via `FILTER NOT EXISTS` so in your case: `PREFIX rdfs: SELECT ?pep ?pepLabel ?relation ?relationLabel ?relatedPerson ?relatedPersonLabel ?endtimequalifier WHERE { VALUES ?pep {wd:Q7747} ?relatedPerson wdt:P31 wd:Q5. ?pep ?relation ?relatedPerson. OPTIONAL{ ?pep p:P26 ?stmt . ?stmt ps:P26 ?spouse. FILTER NOT EXISTS{?stmt pq:P582 ?endtimequalifier } } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } }` – UninformedUser Jan 31 '20 at 13:43
  • https://w.wiki/GSR – Stanislav Kralin Jan 31 '20 at 13:59

0 Answers0