Re: [Tracker] Sparql grouping by year/mont



Hi Michele!

On Fri, Oct 9, 2015 at 4:20 PM, Michele Tameni <michele tameni it> wrote:
Hi all,
I'm working on a small gallery app, and I want to display a list of
year/month where ther is photohraphy taken.

I read the sparql docs and it seems it can be done with month() and  year()
function and then grouping, but trying to execute that query end up in
errors ( It seems they are not implemented atm).

Are you talking about querying information about nmm:Photo resources
from tracker-store? If so, I guess the nie:contentCreated[1] property
holds the 'creation date' of the photo.

The nie:contentCreated property is an xsd:dateTime value, you can use
the fn:month-from-dateTime() and fn:year-from-dateTime() properties to
get month and year values from it.

The following query works for me in Tracker 1.4.1:

SELECT ?url  fn:month-from-dateTime(?d) fn:year-from-dateTime(?d) {
    ?resource a nmm:Photo ;
        nie:contentCreated ?d;
        nie:url ?url
}

Those functions are from the XPath standard, and are documented here:
https://wiki.gnome.org/Projects/Tracker/Documentation/SparqlFeatures

Looking thru the SPARQL 1.1 standard, it does define MONTH() and
YEAR() functions that do the same thing, and Tracker doesn't implement
those, so it's a bit confusing. It would be quite an easy patch to fix
that, if someone has some free time .. :)

Sam

1.https://developer.gnome.org/ontology/stable/nie-InformationElement.html#nie-InformationElement.nie-contentCreated


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]