set echo on; -- ### Optimized version using sub quer SPARQL SELECT DISTINCT ?s1 as ?href, ?name, (bif:search_excerpt (bif:vector ('ceo'), ?o1)) as ?excerpt, ?sc, ?image, (?s1) as ?rank WHERE { { { SELECT DISTINCT * FROM WHERE { ?s1 ?s1textp ?o1 . optional {?s1 foaf:depiction ?image} . ?o1 bif:contains '"ceo"' option (score ?sc). ?s1 a dbpedia-owl:Person. optional {?s1 rdfs:label ?name}. FILTER (lang(?o1) = "en") FILTER (lang(?name) = "en") } ORDER BY DESC (?sc * 3e-1 + sql:rnk_scale ( (?s1))) LIMIT 100 } } } ; -- ### Costly version modulo sub query SPARQL SELECT DISTINCT ?s1 as ?href, ?name, (bif:search_excerpt (bif:vector ('ceo'), ?o1)) as ?excerpt, ?sc, ?image, (?s1) as ?rank WHERE { { { SELECT DISTINCT * WHERE { ?s1 ?s1textp ?o1 . optional {?s1 foaf:depiction ?image} . ?o1 bif:contains '"ceo"' option (score ?sc). ?s1 a dbpedia-owl:Person. optional {?s1 rdfs:label ?name}. FILTER (lang(?o1) = "en") } ORDER BY DESC (?sc * 3e-1 + sql:rnk_scale ( (?s1))) } } } LIMIT 100 ; -- ## Show the bands associated (max 4 degrees of separation) with Grateful Dead entity in DBpedia. SPARQL select ?s as ?Band ?o as ?associated_grp ?dist as ?degrees_of_separation where { { select ?s ?o where { ?s ?o } } option ( transitive, t_distinct, t_in ( ?s ) , t_out ( ?o ) , t_min ( 1 ) , t_max ( 4 ) , t_step ( 'step_no' ) as ?dist ) . filter ( ?s= ) } order by ?dist desc 3 limit 100 ; -- ## Show the bands associated (max 4 degrees of separation) with Grateful Dead entity in DBpedia. -- ## Sort by DESC distance (degrees of separation) SPARQL select ?s as ?Band ?o as ?associated_grp ?dist as ?degrees_of_separation where { { select ?s ?o where { ?s ?o } } option ( transitive, t_distinct, t_in ( ?s ) , t_out ( ?o ) , t_min ( 1 ) , t_max ( 4 ) , t_step ( 'step_no' ) as ?dist ) . filter ( ?s= ) } order by desc ( (?o) ) limit 100 ; -- ## Show the bands associated (max 4 degrees of separation) with Grateful Dead entity in DBpedia. -- ## Sort by DESC entity Rank SPARQL select ?s as ?Band ?o as ?associated_grp ?dist as ?degrees_of_separation ( (?o)) as ?enity_rank where { { select ?s ?o where { ?s ?o } } option ( transitive, t_distinct, t_in ( ?s ) , t_out ( ?o ) , t_min ( 1 ) , t_max ( 4 ) , t_step ( 'step_no' ) as ?dist ) . filter ( ?s= ) } order by desc 4 limit 100 ; 39601 SPARQL select ?link ?g ?step ?path ( (?o) ) as ?entity_rank where { { select ?s ?o ?g where { graph ?g { ?s ?o } } } option ( transitive, t_distinct, t_in ( ?s ) , t_out ( ?o ) , t_no_cycles, T_shortest_only, t_step ( ?s ) as ?link, t_step ( 'path_id' ) as ?path, t_step ( 'step_no' ) as ?step, t_direction 3 ) . filter ( ?s = && bif:isiri_id (?o) && ?o = ) } ORDER BY DESC 5 LIMIT 20 ; -- ##Show the people a person knows directly or indirectly that aren't blank nodes. -- ##Order by distance (degrees of separation) and count of connections of the known person SPARQL select ?o as ?knowee ?dist as ?degrees_of_separation ( ( select count ( * ) where { ?o foaf:knows ?xx } ) ) as ?knowee_connections where { { select ?s ?o where { ?s foaf:knows ?o. filter (!isBlank (?o)) . } } option ( transitive, t_distinct, t_in ( ?s ) , t_out ( ?o ) , t_min ( 1 ) , t_max ( 4 ) , t_step ( 'step_no' ) as ?dist ) . filter ( ?s= ) } order by ?dist desc 3 limit 50 ;