Nepomuk-Core
Classes | |
class | AndTerm |
class | ComparisonTerm |
class | CountQueryRunnable |
class | FileQuery |
class | Folder |
class | FolderConnection |
class | GroupTerm |
class | LiteralTerm |
class | NegationTerm |
class | OptionalTerm |
class | OrTerm |
class | Query |
class | QueryParser |
class | QueryService |
class | QueryServiceClient |
class | ResourceTerm |
class | ResourceTypeTerm |
class | Result |
class | ResultIterator |
class | SearchRunnable |
class | SimpleTerm |
class | Term |
Typedefs | |
typedef QHash< QString, Nepomuk2::Types::Property > | RequestPropertyMap |
Enumerations | |
enum | DateRangeFlag { ModificationDate = 0x1, ContentDate = 0x2, UsageDate = 0x4, AllDates = ModificationDate|ContentDate|UsageDate } |
enum | StandardQuery { LastModifiedFilesQuery, MostImportantResourcesQuery, NeverOpenedFilesQuery, ResourcesForActivityQuery } |
Functions | |
Query | dateRangeQuery (const QDate &start, const QDate &end, DateRangeFlags dateFlags=AllDates) |
Query | operator! (const Query &query) |
Query | operator&& (const Query &query, const Term &term) |
Query | operator|| (const Query &query, const Term &term) |
Query | parseQuery (const QString &s) |
Term | parseTerm (const QString &s) |
uint | qHash (const Result &) |
uint | qHash (const Nepomuk2::Query::Query &) |
uint | qHash (const Nepomuk2::Query::Term &) |
QString | serializeQuery (const Query &query) |
QString | serializeTerm (const Term &term) |
Query | standardQuery (StandardQuery query, const Term &subterm=Term()) |
Detailed Description
The Query namespace contains all classes that make up the Nepomuk Query API.
Constructing queries consists of creating and combining different types of Term subclasses or using the QueryParser to parse user queries (see the QueryParser documentation for details on the query syntax).
The constructed queries can then be executed on the nepomuk query service via the QueryServiceClient, used directly on a Soprano::Model (for example the Nepomuk main model which can be retrieved via ResourceManager::mainModel()), or listed via KIO (see Query::Query::toSearchUrl()).
Constructing Queries
Basically all one needs to know is that each Term matches a set of resources. Different types of terms do so in different ways. The simplest type is the ResourceTerm which matches exactly one resource by URI. The ComparisonTerm matches all resources that have a property with a certain value. The LiteralTerm by itselt matches all resources that contain the string value in one of their properties, and so on.
Thus, constructing a query means to combine all constraints that the results should fulfill using AndTerm and maybe OrTerm. Everything can also the nested and most importantly (this is the one real graph query thing in the API) ComparisonTerm can use any other term as object, meaning it can compare the value of a property (if it is not a literal value) to the results of a subquery. A simple example would be the following:
Fancy Operators
Starting with KDE SC 4.6 queries can be constructed using well known C++ operators. The above examples can now be written as:
Furthermore literal comparisons can now be written as:
- See also
- Query Examples
Typedef Documentation
typedef QHash<QString, Nepomuk2::Types::Property> Nepomuk2::Query::RequestPropertyMap |
Convinience definition for request property mappings as used in QueryServiceClient::sparqlQuery() and QueryServiceClient::blockingSparqlQuery().
Enumeration Type Documentation
Modificators to influence the behaviour of dateRangeQuery().
- Since
- 4.6
Enumerator | |
---|---|
ModificationDate |
Query for the modification date (nie:lastModified) |
ContentDate |
Query for the content creation date (nie:contentCreated) |
UsageDate |
Query for usage events referring to the resource. |
AllDates |
Query for all possible dates. |
Definition at line 76 of file standardqueries.h.
A set of predefined queries that can be created via standardQuery().
- Since
- 4.6
Enumerator | |
---|---|
LastModifiedFilesQuery |
Creates a query that returns all files sorted by descending modification date. The subterm parameter can be used to specify an application restricting the results to files created/opened with that application. |
MostImportantResourcesQuery |
Creates a query that returns all resources sorted by descending score (as calculated by the DataMaintenanceService) The subterm parameter can be used to specify an application restricting the results to files created/opened with that application. |
NeverOpenedFilesQuery |
Creates a query that returns all files with a usage count of 0 sorted by descending modification date. |
ResourcesForActivityQuery |
Get the resources related to a specific activity. Use a ResourceTerm referring to the activity as parameter in standardQuery. |
Definition at line 39 of file standardqueries.h.
Function Documentation
Nepomuk2::Query::Query Nepomuk2::Query::dateRangeQuery | ( | const QDate & | start, |
const QDate & | end, | ||
DateRangeFlags | dateFlags = AllDates |
||
) |
Create a query that returns resources/files that have been modified/accessed in the range from start
to end
(including both full days).
The flags specified in dateFlags
can be used to influence the type of dates that are queried.
- Parameters
-
start The start date of the range, if invalid no start is used, i.e. everything before end
matches.end The end date of the range, if invalid no end is used, i.e. everything after start
matches.dateFlags Optional flags to influence the final query.
- Since
- 4.6
Definition at line 97 of file standardqueries.cpp.
Nepomuk2::Query::Query Nepomuk2::Query::operator! | ( | const Query & | query | ) |
Logical negation operator which negates the meaning of a query.
- See also
- NegationTerm::negateTerm()
- Since
- 4.6
Nepomuk2::Query::Query Nepomuk2::Query::operator&& | ( | const Query & | query, |
const Term & | term | ||
) |
Nepomuk2::Query::Query Nepomuk2::Query::operator|| | ( | const Query & | query, |
const Term & | term | ||
) |
Query Nepomuk2::Query::parseQuery | ( | const QString & | s | ) |
Definition at line 411 of file queryserializer.cpp.
Term Nepomuk2::Query::parseTerm | ( | const QString & | s | ) |
Definition at line 485 of file queryserializer.cpp.
uint Nepomuk2::Query::qHash | ( | const Result & | result | ) |
Definition at line 326 of file folder.cpp.
uint Nepomuk2::Query::qHash | ( | const Nepomuk2::Query::Query & | query | ) |
uint Nepomuk2::Query::qHash | ( | const Nepomuk2::Query::Term & | term | ) |
QString Nepomuk2::Query::serializeQuery | ( | const Query & | query | ) |
Definition at line 352 of file queryserializer.cpp.
QString Nepomuk2::Query::serializeTerm | ( | const Term & | term | ) |
Definition at line 471 of file queryserializer.cpp.
Nepomuk2::Query::Query Nepomuk2::Query::standardQuery | ( | StandardQuery | query, |
const Term & | subterm = Term() |
||
) |
Create a standard query as defined by query
.
- Parameters
-
query The query to be generated. See StandardQuery. subterm An optional subterm used for specific types of standard queries that need a parameter like ResourcesForActivityQuery.
To get a query that only returns files (this is already true for some of the predefined queries) use something like the following:
Be aware that queries can be combined. One can for example get the most important files related to an activity as follows:
- Since
- 4.6
Definition at line 40 of file standardqueries.cpp.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:09 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.