tracker-sparql command_examples

tracker-sparql command_examples

tracker-sparql – Use SparQL to query the Tracker databases.

List all classes

$ tracker-sparql -q "SELECT ?cl WHERE { ?cl a rdfs:Class }"

List all properties for the Resources class (see –list-properties)

$ tracker-sparql -q "SELECT ?prop WHERE {
?prop a rdf:Property ;


List all class namespace prefixes

$ tracker-sparql -q "SELECT ?prefix ?ns WHERE {
?ns a tracker:Namespace ;
tracker:prefix ?prefix


List all music files

$ tracker-sparql -q "SELECT ?song WHERE { ?song a nmm:MusicPiece }"

List all music albums

$ tracker-sparql -q "SELECT ?album ?title COUNT(?song)
AS songs
SUM(?length) AS totallength
?album a nmm:MusicAlbum ;
nie:title ?title .
?song nmm:musicAlbum ?album ;
nfo:duration ?length
} GROUP BY ?album"


List all music from a particular artist

$ tracker-sparql -q "SELECT ?song ?title WHERE {
?song nmm:performer [ nmm:artistName 'Artist Name' ] ;
nie:title ?title


Set the played count for a song

$ tracker-sparql -u -q "DELETE {
nie:usageCounter ?count
nie:usageCounter ?count
nie:usageCounter 42


List all image files

$ tracker-sparql -q "SELECT ?image WHERE { ?image a nfo:Image }"

List all image files with a specific tag

$ tracker-sparql -q "SELECT ?image WHERE {
?image a nfo:Image ;
nao:hasTag [ nao:prefLabel 'tag' ]


List all image files created on a specific month and order by date

$ tracker-sparql -q "SELECT ?image ?date WHERE {
?image a nfo:Image ;
nie:contentCreated ?date .
FILTER (?date >= '2008-07-01T00:00:00' &&
?date < '2008-08-01T00:00:00')
} ORDER BY ?date"


Leave a Reply

Your email address will not be published. Required fields are marked *