Nepomuk
#include <Nepomuk/Query/Query>
Classes | |
class | RequestProperty |
Public Types | |
enum | QueryFlag { NoQueryFlags = 0x0, NoResultRestrictions = 0x1, WithoutFullTextExcerpt = 0x2 } |
enum | SparqlFlag { NoFlags = 0x0, CreateCountQuery = 0x1, HandleInverseProperties = 0x2, CreateAskQuery = 0x4 } |
Public Member Functions | |
Query () | |
Query (const Term &term) | |
Query (const Query &) | |
~Query () | |
void | addRequestProperty (const RequestProperty &property) |
bool | fullTextScoringEnabled () const |
Qt::SortOrder | fullTextScoringSortOrder () const |
bool | isFileQuery () const |
bool | isValid () const |
int | limit () const |
int | offset () const |
bool | operator!= (const Query &query) const |
Query & | operator= (const Query &) |
Query & | operator= (const Term &term) |
bool | operator== (const Query &query) const |
Query | optimized () const |
QueryFlags | queryFlags () const |
QList< RequestProperty > | requestProperties () const |
RequestPropertyMap | requestPropertyMap () const |
void | setFullTextScoringEnabled (bool enabled) |
void | setFullTextScoringSortOrder (Qt::SortOrder order) |
void | setLimit (int) |
void | setOffset (int offset) |
void | setQueryFlags (QueryFlags flags) |
void | setRequestProperties (const QList< RequestProperty > &properties) |
void | setTerm (const Term &) |
Term | term () const |
FileQuery | toFileQuery () const |
KUrl | toSearchUrl (SparqlFlags flags=NoFlags) const |
KUrl | toSearchUrl (const QString &customTitle, SparqlFlags flags=NoFlags) const |
QString | toSparqlQuery (SparqlFlags flags=NoFlags) const |
QString | toString () const |
Static Public Member Functions | |
static Query | fromQueryUrl (const KUrl &url) |
static Query | fromString (const QString &queryString) |
static QString | sparqlFromQueryUrl (const KUrl &url) |
static QString | titleFromQueryUrl (const KUrl &url) |
Detailed Description
A Nepomuk desktop query.
A Query consists or a combination of Terms that can be optionally restricted via a limit (setLimit()) or folder filters (setIncludeFolders() and setExcludeFolders()).
Additionally setRequestProperties() allows to retrieve additional information about the results.
Queries can be easily converted to SPARQL via the toSparqlQuery() method or to search URLs ready for KIO::DirLister using toSearchUrl().
The typical usage of a Query instance would be QueryServiceClient::query(). However one can also use toSparqlQuery() to convert it into a SPARQL query string and use that string in QueryServiceClient::sparqlQuery() or even directly in Soprano::Model::executeQuery() via ResourceManager::instance()->mainModel()
or in a custom Model.
- See also
- QueryParser, FileQuery
- Since
- 4.4
Member Enumeration Documentation
A set of flags that influence the result of the query.
- See also
- setQueryFlags(), SparqlFlags
- Since
- 4.6
Enumerator | |
---|---|
NoQueryFlags |
No flags set. This is the default. |
NoResultRestrictions |
By default queries that will only return results which are intended for the user's eyes. In situations where an application needs to work on internal or statistical data this restriction is not desireable. This flag disables the restriction and returns the full set of results. |
WithoutFullTextExcerpt |
Disables the return of full text search excerpts for ComparisonTerm::Contains terms which are normally reported through Result::excerpt(). It might make sense to set this flag in case one has no need for excerpts and does not want to suffer the small performance penalty that comes from querying them |
Aditional flags modifying the behaviour of toSparqlQuery() and toSearchUrl().
Constructor & Destructor Documentation
Nepomuk::Query::Query::Query | ( | ) |
Create an empty invalid query object.
|
explicit |
Create a query with root term term.
Nepomuk::Query::Query::Query | ( | const Query & | ) |
Copy constructor.
Nepomuk::Query::Query::~Query | ( | ) |
Destructor.
Member Function Documentation
void Nepomuk::Query::Query::addRequestProperty | ( | const RequestProperty & | property | ) |
Add a property that should be reported with each search result.
- Parameters
-
property The requested property.
ComparisonTerm::setVariableName() provides a more flexible (but also slightly more complicated) way to select additional results.
|
static |
Extract a query from a nepomuksearch:/ query URL.
- Returns
- The query that was encoded in
url
or an invalid query if eitherurl
is not a nepomuksearch:/ URL or if it contains a pure SPARQL query. In the latter case sparqlFromQueryUrl() can be used to extract that query.
- See also
- sparqlFromQueryUrl()
- Since
- 4.5
|
static |
Parse a Query that has been encoded as a string via toString().
- Warning
- This method can NOT parse SPARQL syntax.
- See also
- toString()
- Since
- 4.5
bool Nepomuk::Query::Query::fullTextScoringEnabled | ( | ) | const |
Qt::SortOrder Nepomuk::Query::Query::fullTextScoringSortOrder | ( | ) | const |
- Returns
- The full text scoring sort order as set via setFullTextScoringSortOrder()
- Since
- 4.6
bool Nepomuk::Query::Query::isFileQuery | ( | ) | const |
- Returns
true
if this is a file query that will only return files and folders.
- See also
- FileQuery
- Since
- 4.5
bool Nepomuk::Query::Query::isValid | ( | ) | const |
- Returns
true
if the query is valid, i.e. it has a valid term().
int Nepomuk::Query::Query::limit | ( | ) | const |
The maximum number of results that this query should yield.
- See also
- setLimit()
int Nepomuk::Query::Query::offset | ( | ) | const |
bool Nepomuk::Query::Query::operator!= | ( | const Query & | query | ) | const |
Comparison operator.
- Returns
true
if this query differs fromquery
.
- Since
- 4.6
Assignment operator.
Assigns term
to this query without changing any other properties.
- Since
- 4.5
bool Nepomuk::Query::Query::operator== | ( | const Query & | query | ) | const |
Comparison operator.
- Returns
true
if this query is equal toquery
.
Query Nepomuk::Query::Query::optimized | ( | ) | const |
Optimizes the query without chaning its meaning.
This removes redundant terms such as NegationTerm and OptionalTerm nestings and flattens AndTerm and OrTerm hierarchies.
- Returns
- An optimized version of this query.
- Since
- 4.6
- See also
- Term::optimized()
QueryFlags Nepomuk::Query::Query::queryFlags | ( | ) | const |
QList<RequestProperty> Nepomuk::Query::Query::requestProperties | ( | ) | const |
- Returns
- The list of RequestProperty instances set via addRequestProperty and setRequestProperties.
RequestPropertyMap Nepomuk::Query::Query::requestPropertyMap | ( | ) | const |
Build a request property map as used in QueryServiceClient::sparqlQuery() from the request properties set via addRequestProperty() and setRequestProperties().
Be aware that in most situations it is much simpler to use QueryServiceClient::query().
void Nepomuk::Query::Query::setFullTextScoringEnabled | ( | bool | enabled | ) |
Nepomuk supports scoring the results based on any full text matching used in the query (full text matching is done via ComparisonTerm with the ComparisonTerm::Contains comperator) and sorting the results based on that score.
By default full text scoring is disabled since it can mean a serious impact on query performance.
- Since
- 4.6
void Nepomuk::Query::Query::setFullTextScoringSortOrder | ( | Qt::SortOrder | order | ) |
Set the full text scoring sort order.
Ignored if full text scoring is disabled.
By default the sort order is Qt::DescendingOrder.
- See also
- setFullTextScoringEnabled()
- Since
- 4.6
void Nepomuk::Query::Query::setLimit | ( | int | ) |
Set the maximum number of results this query should yield.
- See also
- limit
void Nepomuk::Query::Query::setOffset | ( | int | offset | ) |
The first result that should be retrieved.
This can be combined with setLimit() to do paged results.
- Since
- 4.5
void Nepomuk::Query::Query::setQueryFlags | ( | QueryFlags | flags | ) |
void Nepomuk::Query::Query::setRequestProperties | ( | const QList< RequestProperty > & | properties | ) |
Set the properties that should be reported with each search result.
- Parameters
-
properties The requested properties.
ComparisonTerm::setVariableName() provides a more flexible (but also slightly more complicated) way to select additional results.
|
static |
Extract the SPARQL query from a nepomuksearch:/ query URL.
All kinds of nepomuksearch:/ URLs are supported.
- Returns
- The SPARQL query string representing the query encoded in
url
.
- See also
- fromQueryUrl()
- Since
- 4.5
Term Nepomuk::Query::Query::term | ( | ) | const |
|
static |
Extact the title from a nepomuksearch:/ query URL.
The title is either a custom title which has been specified in toSearchUrl(const QString&, SparqlFlags) or the user query string in case of nepomuksearch:/myquery URLs.
- Returns
- A title for the query
url
or an empty string in caseurl
is not a nepomuksearch:/ URL or a useful title cannot be extracted.
- Since
- 4.5
FileQuery Nepomuk::Query::Query::toFileQuery | ( | ) | const |
- Returns
- A copy of this query which is restricted to files.
- Since
- 4.6
KUrl Nepomuk::Query::Query::toSearchUrl | ( | SparqlFlags | flags = NoFlags | ) | const |
Convert the query into a URL which can be listed using KIO::DirLister.
The URL will use the nepomuksearch:/
KIO protocol to handle the listing of search results.
- Parameters
-
flags Optional flags to change the query. Query::CreateCountQuery is not supported and will silently be dropped from flags
.
- Returns
- A URL which will list a virtual folder containing all search results from this query or an invalid URL in case this query is invalid.
- See also
- toSparqlQuery(), SparqlFlag
KUrl Nepomuk::Query::Query::toSearchUrl | ( | const QString & | customTitle, |
SparqlFlags | flags = NoFlags |
||
) | const |
Convert the query into a URL which can be listed using KIO::DirLister.
The URL will use the nepomuksearch:/
KIO protocol to handle the listing of search results.
This is the perfect method for listing results in file managers or file dialogs.
- Parameters
-
customTitle An optional custom title that will be used for the listing of the results. This is achieved by setting the KIO::UDSEntry::UDS_DISPLAY_NAME to the customTitle value. flags Optional flags to change the query. Query::CreateCountQuery is not supported and will silently be dropped from flags
.
- Returns
- A URL which will list a virtual folder containing all search results from this query or an invalid URL in case this query is invalid.
- See also
- toSparqlQuery(), SparqlFlag
- Since
- 4.5
QString Nepomuk::Query::Query::toSparqlQuery | ( | SparqlFlags | flags = NoFlags | ) | const |
Convert the query into a SPARQL query which can be used with the Nepomuk query service or directly in Soprano::Model::executeQuery.
It is recommended to use QueryServiceClient instead of creating the SPARQL query this way.
The resulting query will bind the results to variable 'r'
. Request properties will be bound to variables 'reqProp1'
through 'reqPropN'
(the only exception is a count query created via the CreateCountQuery flag).
If you are looking for a serialization of a Query which can be parsed again use toString() instead.
- Warning
- The SPARQL queries created by this method contain SPARQL extensions from Virtuoso and will not work with other RDF storage solutions!
- Parameters
-
flags Optional flags to change the query.
- Returns
- The SPARQL representation of this query or an empty string if the query could not be converted (invalid query.)
- See also
- toString(), toSearchUrl(), SparqlFlag
QString Nepomuk::Query::Query::toString | ( | ) | const |
Encode the Query in a string.
Be aware that this does NOT create a SPARQL query. The returned string can be used to serialize queries that can later be read via fromString().
- See also
- fromString(), toSparqlQuery()
- Since
- 4.5
The documentation for this class was generated from the following file:
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:02 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.