CONSTRUCT { .. } WHERE { { <"+resource.getURI()+"> ?props ?ob ." // All triples where this resource is the subject OPTIONAL { // and the properties of its first neighbour ?ob ?secprop ?secob. } } UNION { ?sub ?propo <"+resource.getURI()+"> // All triples where this resource is the object OPTIONAL { ?sub ?secpropofr ?secobofr." + } } }