< Development‎ | Tutorials‎ | Metadata/Nepomuk
Revision as of 00:05, 18 August 2009 by Thekidder (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Nepomuk Query Service
Tutorial Series   Nepomuk
Previous   Strigi Service
What's Next  
Further Reading   Nepomuk Services, Nepomuk Server

Nepomuk Query Service

The Query service provides a D-Bus interfaces named org.kde.nepomuk.QueryService which is exported at nepomukqueryservice. This interface allows to issue queries using a simple user language (most importantly one can use AND and OR to combine terms and field:value terms to query certain fields. In the latter case value will be matched to a literal value or the label of a resource in case the property matching field has a non-literal range.)

Calling the query method will return the path to a new D-Bus object which provides the interface org.kde.nepomuk.Query. The latter interface allows to list the results and emits signals for new or removed results.

Normally one would use the libnepomukqueryclient library provided by kdebase/workspace to access this services.

Another possibility is the Nepomuk Query KIO slave named nepomuksearch. This will return results formatted as UDSEntries.

Using the nepomuksearch:/ kioslave

There are two search types available: the simple query syntax and a method to directly open SPARQL queries.
The legacy search method is to simply open

nepomuksearch:/<simple search query>

This is deprecated. Instead, to open a simple query you should open

nepomuksearch:/?query=<simple search query>

and to open a SPARQL query you should open

nepomuksearch:/?sparql=<sparql query>

Simple Search Syntax

The search syntax in Dolphin is as follows:
expression logicop...
logicop = and | or
expression = text | negation field operand value
operand = : | = | > | < | <= | >=
field: any ontology property
negation: + | -

The negation term is positive if unspecified.

Field refers to any ontology properties. Some common properties:
lastModified: resource modification date
contentSize: resource size
artist, album, title, year, genre, trackNumber, discNumber: music metadata
hasTag: search by tag
rating: a 1 - 10 rating

Some examples:

search for the word nepomuk in the file name, content, comment, or other indexed field


search for resources with a size greater than 1000KiB. Supported size postfixes: KB, KiB, MB, MiB, GB, GiB, TB, TiB. These are case sensitive

nepomuksearch:/?query=rating<2 or rating>8

search for resources WITHOUT the tag nepomuk

SPARQL syntax

Opening a SPARQL query is as simple as opening the URL

nepomuksearch:/?sparql=<sparql query>

The sparql query should have the variable ?r as one of the select variables. Simple ontology prefixes are possible: nie, nfo, rdf, rdfs, nrl, nao, xsd, pimo.

nepomuksearch:/?sparql=select ?r where { ?r nie:hasTag <nepomuk:/nepomuk> }

select all resources tagged with "nepomuk"

Much of this search functionality is only available in the GSoC soc-virtualfolders branch. It will be merged to trunk in time for 4.4.

This page was last modified on 18 August 2009, at 00:05. Content is available under Creative Commons License SA 4.0 unless otherwise noted.