tracker sparql -q <sparql> [-u] | -f <file> tracker sparql -t [class] [-s <needle>] [-p] tracker sparql [-c] [-p] [-x] [-n [class]] [-i [property]] [-s <needle>] tracker sparql [--get-longhand <class>] [--get-shorthand <class>]
When the caller runs a query, the query is in RDF and SPARQL. This can be done two ways. Either by providing a file with the query or by providing a string with the sparql query.
The file argument can be either a local path or a URI. It also does not have to be an absolute path.
"SELECT ?u WHERE { ?u a rdfs:Resource }"
This gives the following result:
$ tracker sparql -p nfo:Video Properties: 2 http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#frameRate http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#frameCount
These properties nfo:frameRate and nfo:frameCount can then be used in queries.
See also --tree and --query.
$ tracker sparql -t nmo:MMSMessage ROOT +-- rdfs:Resource (C) | +-- nie:InformationElement (C) | | +-- nfo:Document (C) | | | +-- nfo:TextDocument (C) | | | | `-- nmo:Message (C) | | | | | +-- nmo:PhoneMessage (C) | | | | | | `-- nmo:MMSMessage (C)
If no class is given, the entire tree is shown.
The --search command line option can be used to highlight parts of the tree you're looking for. The search is case insensitive.
The --properties command line option can be used to show properties for each class displayed, for example:
$ tracker sparql -t nfo:FileDataObject -p ROOT +-- rdfs:Resource (C) | --> http://purl.org/dc/elements/1.1/contributor (P) | --> http://purl.org/dc/elements/1.1/coverage (P) | --> http://purl.org/dc/elements/1.1/creator (P) | --> http://purl.org/dc/elements/1.1/date (P) | --> http://purl.org/dc/elements/1.1/description (P) | --> http://purl.org/dc/elements/1.1/format (P) | --> http://purl.org/dc/elements/1.1/identifier (P) | --> http://purl.org/dc/elements/1.1/language (P) | --> http://purl.org/dc/elements/1.1/publisher (P) | --> http://purl.org/dc/elements/1.1/relation (P) | --> http://purl.org/dc/elements/1.1/rights (P) | --> http://purl.org/dc/elements/1.1/source (P) | --> http://purl.org/dc/elements/1.1/subject (P) | --> http://purl.org/dc/elements/1.1/title (P) | --> http://purl.org/dc/elements/1.1/type (P) | --> nao:deprecated (P) | --> nao:hasTag (P) | --> nao:identifier (P) | --> nao:isRelated (P) | --> nao:lastModified (P) | --> nao:numericRating (P) | --> rdf:type (P) | --> rdfs:comment (P) | --> rdfs:label (P) | --> tracker:added (P) | --> tracker:damaged (P) | --> tracker:modified (P) | +-- nie:DataObject (C) | | --> nfo:belongsToContainer (P) | | --> nie:byteSize (P) | | --> nie:created (P) | | --> nie:dataSource (P) | | --> nie:interpretedAs (P) | | --> nie:isPartOf (P) | | --> nie:lastRefreshed (P) | | --> nie:url (P) | | --> tracker:available (P) | | +-- nfo:FileDataObject (C) | | | --> nfo:fileCreated (P) | | | --> nfo:fileLastAccessed (P) | | | --> nfo:fileLastModified (P) | | | --> nfo:fileName (P) | | | --> nfo:fileOwner (P) | | | --> nfo:fileSize (P) | | | --> nfo:hasHash (P) | | | --> nfo:permissions (P)
$ tracker sparql -s text Classes: 4 http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#TextDocument http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#PlainTextDocument http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#PaginatedTextDocument http://www.tracker-project.org/temp/nmm#SynchronizedText Properties: 4 http://www.tracker-project.org/ontologies/tracker#fulltextIndexed http://www.semanticdesktop.org/ontologies/2007/01/19/nie#plainTextContent http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#plainTextMessageContent http://www.tracker-project.org/temp/scal#textLocation
See also --tree.
$ tracker sparql --get-shorthand http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#plainTextMessageContent nmo:plainTextMessageContent
$ tracker sparql --get-longhand nmm:MusicPiece http://www.tracker-project.org/temp/nmm#MusicPiece
With "direct" the connection to the database is made directly to the file itself on the disk, there is no intermediary daemon or process. The "direct" approach is purely read-only.
With "bus" the tracker-store process is used to liase with the database queuing all requests and managing the connections via an IPC / D-Bus. This adds a small overhead BUT this is the only approach you can use if you want to write to the database.
With "auto" the backend is decided for you, much like it would be if this environment variable was undefined.
$ tracker sparql -q "SELECT ?cl WHERE { ?cl a rdfs:Class }"
$ tracker sparql -q "SELECT ?prop WHERE { ?prop a rdf:Property ; rdfs:domain <http://www.w3.org/2000/01/rdf-schema#Resource> }"
$ tracker sparql -q "SELECT ?prefix ?ns WHERE { ?ns a tracker:Namespace ; tracker:prefix ?prefix }"
$ tracker sparql -q "SELECT ?song WHERE { ?song a nmm:MusicPiece }"
$ tracker sparql -q "SELECT ?title COUNT(?song) AS songs SUM(?length) AS totallength WHERE { ?album a nmm:MusicAlbum ; nie:title ?title . ?song nmm:musicAlbum ?album ; nfo:duration ?length } GROUP BY ?album"
$ tracker sparql -q "SELECT ?song ?title WHERE { ?song nmm:performer [ nmm:artistName 'Artist Name' ] ; nie:title ?title }"
$ tracker sparql -u -q "DELETE { <file:///home/user/Music/song.mp3> nie:usageCounter ?count } WHERE { <file:///home/user/Music/song.mp3> nie:usageCounter ?count } INSERT { <file:///home/user/Music/song.mp3> nie:usageCounter 42 }"
$ tracker sparql -q "SELECT ?image WHERE { ?image a nfo:Image }"
$ tracker sparql -q "SELECT ?image WHERE { ?image a nfo:Image ; nao:hasTag [ nao:prefLabel 'tag' ] }"
$ 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"