• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

Nepomuk

  • Nepomuk
  • Query
  • QueryParser
Public Types | Public Member Functions | Static Public Member Functions | List of all members
Nepomuk::Query::QueryParser Class Reference

#include <Nepomuk/Query/QueryParser>

Public Types

enum  ParserFlag { NoParserFlags = 0x0, QueryTermGlobbing = 0x1, DetectFilenamePattern = 0x2 }
 

Public Member Functions

 QueryParser ()
 
 ~QueryParser ()
 
QList< Types::Property > matchProperty (const QString &fieldName) const
 
Query parse (const QString &query) const
 
Query parse (const QString &query, ParserFlags flags) const
 

Static Public Member Functions

static Query parseQuery (const QString &query)
 
static Query parseQuery (const QString &query, ParserFlags flags)
 

Detailed Description

Parser for desktop user queries.

Warning
This is NOT a SPARQL parser.

The QueryParser can be used to parse user queries, ie. queries that the user would enter in any search interface, and convert them into Query instances.

The syntax is fairly simple: plain strings match to LiteralTerm terms, URIs need to be N3-encoded, when using white space parenthesis need to be put around properties and values, terms can be excluded via '-'.

Examples

Query everything that contains the term "nepomuk":

nepomuk

Query everything that contains both the terms "Hello" and "World":

Hello World

Query everything that contains the term "Hello World":

"Hello World"

Query everything that has a tag whose label matches "nepomuk" (actually this is where Query::resolveProperties would match "hastag" to nao:hasTag):

hastag:nepomuk

Query everything that has a tag labeled "nepomuk" or a tag labeled "scribo:

hastag:nepomuk OR hastag:scribo

Query everything that has a tag labeled "nepomuk" but not a tag labeled "scribo":

+hastag:nepomuk AND -hastag:scribo

The parser can handle one special case of nesting (TODO: implement a "real" parser) which matches all resources that are related to a resource which in turn has a certain property:

related:(hastag:nepomuk)
Author
Sebastian Trueg trueg.nosp@m.@kde.nosp@m..org
Since
4.4

Definition at line 90 of file queryparser.h.

Member Enumeration Documentation

enum Nepomuk::Query::QueryParser::ParserFlag

Flags to change the behaviour of the parser.

Since
4.5
Enumerator
NoParserFlags 

No flags.

Default for parse()

QueryTermGlobbing 

Make each full text term use a '*' wildcard to match longer strings ('foobar' is matched by 'foob*').

Be aware that the query engine needs at least 4 chars to do globbing though.

This is disabled by default.

DetectFilenamePattern 

Try to detect filename pattern like *.mp3 or hello*.txt and create appropriate ComparisonTerm instances using ComparisonTerm::Regexp instead of ComparisonTerm::Contains.

Since
4.6

Definition at line 108 of file queryparser.h.

Constructor & Destructor Documentation

Nepomuk::Query::QueryParser::QueryParser ( )

Create a new query parser.

Nepomuk::Query::QueryParser::~QueryParser ( )

Destructor.

Member Function Documentation

QList<Types::Property> Nepomuk::Query::QueryParser::matchProperty ( const QString &  fieldName) const

Try to match a field name as used in a query string to actual properties.

The matching is cached inside the Query instance for fast subsequent lookups.

Example:

hastag:nepomuk
Returns
A list of properties that match fieldName or an empty list in case nothing was matched.

This method is used by parse() to match properties used in user queries.

Query Nepomuk::Query::QueryParser::parse ( const QString &  query) const

Parse a user query.

Returns
The parsed query or an invalid Query object in case the parsing failed.
Query Nepomuk::Query::QueryParser::parse ( const QString &  query,
ParserFlags  flags 
) const

Parse a user query.

Parameters
queryThe query string to parse
flagsa set of flags influencing the parsing process.
Returns
The parsed query or an invalid Query object in case the parsing failed.
Since
4.5
static Query Nepomuk::Query::QueryParser::parseQuery ( const QString &  query)
static

Convenience method to quickly parse a query without creating an object.

Returns
The parsed query or an invalid Query object in case the parsing failed.
static Query Nepomuk::Query::QueryParser::parseQuery ( const QString &  query,
ParserFlags  flags 
)
static

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
queryThe query string to parse
flagsa set of flags influencing the parsing process.
Since
4.6

The documentation for this class was generated from the following file:
  • queryparser.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:27 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Nepomuk

Skip menu "Nepomuk"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal