Fix complex query 9
@@ -8,32 +8,36 @@ PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dbpedia: <http://dbpedia.org/resource/>
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
-select
+SELECT
(?fr AS ?personId)
(?first AS ?personFirstName)
(?last AS ?personLastName)
(?post AS ?commentOrPostId)
(?content AS ?commentOrPostContent)
- (?date AS ?commentOrPostCreationDate)
-where {
+ (?creationDate AS ?commentOrPostCreationDate)
+WHERE {
+ VALUES (?type) {(snvoc:Comment) (snvoc:Post)}
{
- select distinct ?fr
- where {
- { sn:pers$Person snvoc:knows ?fr . }
- union
+ SELECT DISTINCT
+ ?fr
+ ?frId
+ WHERE
{
- sn:pers$Person snvoc:knows ?fr2 .
- ?fr2 snvoc:knows ?fr .
- filter (?fr != sn:pers$Person)
- }
- }
+ BIND( "$personId"^^xsd:long AS ?rootId )
+ ?rootPerson a snvoc:Person .
+ ?rootPerson snvoc:id ?rootId .
+ ?rootPerson ((snvoc:knows/snvoc:hasPerson)|^(snvoc:knows/snvoc:hasPerson))?/((snvoc:knows/snvoc:hasPerson)|^(snvoc:knows/snvoc:hasPerson)) ?fr .
+ ?fr snvoc:id ?frId .
+ FILTER(?frId != ?rootId)
}
+ } .
+ ?message a ?type .
+ ?message snvoc:hasCreator ?fr .
+ ?message snvoc:creationDate ?creationDate .
+ FILTER (?creationDate < $date) .
+ ?message snvoc:content|snvoc:imageFile ?content .
?fr snvoc:firstName ?first .
?fr snvoc:lastName ?last .
- ?post snvoc:hasCreator ?fr .
- ?post snvoc:creationDate ?date .
- filter (?date < $Date0) .
- {{?post snvoc:content ?content} union {?post snvoc:imageFile ?content}} .
}
-order by desc(?creationDate) ?post
-limit 20
+ORDER BY DESC(?creationDate) ?post
+LIMIT 20
