General Examples

Get list of all available classes

tracker sparql -q "SELECT ?s WHERE { ?s rdf:type rdfs:Class . }"

Get list of all available properties

tracker sparql -q "SELECT ?s WHERE { ?s rdf:type rdf:Property . }"

Get list of all classes in use

tracker sparql -q "SELECT DISTINCT ?o WHERE { ?s rdf:type ?o . }"

Get list of all properties in use

tracker sparql -q "SELECT DISTINCT ?p WHERE { ?s ?p ?o . }" # Not possible in Tracker as of writing

Get list of all known items

tracker sparql -q "SELECT ?s WHERE { ?s rdf:type nie:InformationElement . }"

Get all info about home dir

# this is like "tracker info $HOME"
tracker sparql -q "SELECT ?u { ?u nie:url 'file://$HOME' . }
Results:
  urn:uuid:xyz

tracker sparql -q "SELECT * WHERE { <urn:uuid:xyz> ?p ?o . }"

Get list of all known files in home dir

tracker sparql -q "SELECT ?url WHERE { ?s a nfo:FileDataObject ; nie:url ?url . FILTER (STRSTARTS (?url, 'file://$HOME/' . }"

Update as MusicPieces the objects that have the Mime Type "audio/foo"

tracker sparql -u -q "INSERT { ?urn a nmm:MusicPiece . } WHERE { ?urn nie:mimeType \"audio/foo\" . }"

Get files that match either criteria

Use UNION to get files where either file name contains "physics" or where the title contains "physics".

tracker sparql -q "SELECT nie:url(?s)                                            
WHERE {                                                                          
    ?s a nfo:FileDataObject .                                                    
    ?s nie:url ?url .                                                            
    {                                                                            
        ?s nfo:fileName ?name .                                                  
        FILTER (CONTAINS(LCASE(?name), 'physics'))                    
    } UNION {                                                                    
        ?s nie:title ?title .                                                    
        FILTER (CONTAINS(LCASE(?title), 'physics'))                   
    }                                                                            
}"

Projects/Tracker/Documentation/Examples/SPARQL/General (last edited 2017-03-10 13:16:02 by CarlosGarnacho)