This site has been retired. For up to date information, see handbook.gnome.org or gitlab.gnome.org.


[Home] [TitleIndex] [WordIndex

1. Tagging

1.1. Get all tags with label mylabel

SELECT ?tag 
WHERE {
  ?tag a nao:Tag .
  ?tag nao:prefLabel 'mylabel' .
}

1.2. Get all tags for a file

SELECT ?tags ?labels 
WHERE {
  ?f nie:isStoredAs ?as ;
     nao:hasTag ?tags .
  ?as nie:url 'file:///home/path/to/file.txt' .
  ?tags a nao:Tag ;
     nao:prefLabel ?labels .
} ORDER BY ASC(?labels)

1.3. Creating a new tag

INSERT { 
  _:tag a nao:Tag ;
        nao:prefLabel 'mylabel' .
} WHERE {
  OPTIONAL {
     ?tag a nao:Tag ;
          nao:prefLabel 'mylabel'
  } .
  FILTER (!bound(?tag)) 
} 

1.4. Adding a tag that already exists to urn:XXX:ZZZ

INSERT { 
  <urn:XXX:ZZZ> nao:hasTag ?id 
} 
WHERE {
  ?id nao:prefLabel 'mylabel' 
}

1.5. Adding a new tag to a file

INSERT {
  _:tag a nao:Tag ;
        nao:prefLabel 'mylabel' .
  ?unknown nao:hasTag _:tag  
} WHERE {
  ?unknown nie:isStoredAs ?as .
  ?as nie:url 'file:///home/path/file'
}

1.6. Adding an existing tag to a file

INSERT {
  ?unknown nao:hasTag ?id 
} WHERE {
  ?unknown nie:isStoredAs ?as .
  ?as nie:url 'file:///home/path/file' .
  ?id nao:prefLabel 'mylabel' 
}

1.7. Removing a tag regardless of associated URNs

DELETE { 
  ?tag a nao:Tag 
} 
WHERE {
  ?tag nao:prefLabel 'mylabel'
}

1.8. Removing a tag for a URN

DELETE { 
  ?f nao:hasTag ?t 
} 
WHERE { 
  ?f nao:hasTag <urn:for:tag> 
}

2. A few complete examples

For files:

tracker-sparql -u -q "INSERT { 
   <file:///home/path/file> a nfo:Document, nfo:FileDataObject ; 
         nie:isStoredAs <file:///home/path/file> ; 
         nie:url 'file:///home/path/file' 
}"

tracker-sparql -u -q "INSERT {
  _:tag a nao:Tag ;
        nao:prefLabel 'mylabel' .
  ?unknown nao:hasTag _:tag  
} WHERE {
  ?unknown nie:isStoredAs ?as .
  ?as nie:url 'file:///home/path/file'
}"

tracker-sparql -q "SELECT ?tags ?labels 
WHERE {
  ?f nie:isStoredAs ?d ;
     nao:hasTag ?tags .
  ?d nie:url <file:///home/path/file> .
  ?tags a nao:Tag ;
     nao:prefLabel ?labels .
} ORDER BY ASC(?labels)"
Result: 1
  urn:uuid:YYY-XXX-..., mylabel

Any kind of resource:

tracker-sparql -u -q "INSERT { <urn:XXX:ZZZ> a rdfs:Resource }"

# This assumes the tag already exists from example above
tracker-sparql -u -q "INSERT { 
  <urn:XXX:ZZZ> nao:hasTag ?id 
} WHERE {
  ?id nao:prefLabel 'mylabel' 
}"

tracker-sparql -q "SELECT ?label 
WHERE { 
  <urn:XXX:ZZZ> nao:hasTag ?tag .
  ?tag nao:prefLabel ?label 
}"
Result: 1
  mylabel


2024-10-23 10:59