Syntax
They query syntax is based on SMW’s (http://semantic-mediawiki.org/wiki/Help:Selecting_pages).
Queries are made up of a series of conditions, followed by a series of parameters joined by |. Conditions are logically ANDed together. Parameters affect the presentation of the query results.
Get the pages with a relationship department
having a value Development
.
[[department::Development]]
Format the results as an unordered list.
[[department::Development]] | format=ul
Get the pages with a relationship department
having a value Development
and a relationship gender
having a value male
.
[[department::Development]] [[gender::male]] | format=ul
Get the pages with a relationship department
having a value Development
and a relationship degree
having any value.
[[department::Development]] [[degree::+]]
Use Dept
as the heading for the column department
.
[[department::Development]] | ?department=Dept
Comparators
Token |
Description |
Example |
< |
less than |
[[age::<100]] [[name::<M]] |
> |
greater than |
[[age::>100]] [[name::>M]] |
! |
not |
[[age::!100]] [[name::!Richard]] |
~ |
like (string relationships only) |
[[name::~vander]] |
+ |
has value |
[[age::+]] |
. |
this page (the title of the current page is used as the value) |
[[link::.]] |
Supported Parameters
Parameter |
Description |
mainlabel |
The label of the main (first) column. Defaults to blank. |
format |
The output format (see below). Defaults to table . |
sort |
Field or relationship to sort on. Valid options are: title , -title , date , -date or any simple relationship name. date is the page revision date. Defaults to title . |
limit |
Limit the results to this many. |
offset |
0-based index of the result to start with. Use with sort. |
searchlabel |
Text used to link to the full results if results are limited. Set to blank to hide the link. Defaults to «… further results» . |
values |
Return all values for the given relationship type. See below. |
relationships |
Return all relationship types. See below. |
Format |
Description |
list |
Comma-separated list, with additional column data shown in parentheses |
ol |
Ordered list, with additional column data shown in parentheses |
ul |
Bulleted list, with additional column data shown in parentheses |
table |
Tabular output |
csv |
Export result table as CSV (comma-separated values) |
section |
Wiki segments (<div> tags in HTML with label as CSS class) |
segment |
Wiki sections (<span> tags in HTML with label as CSS class) |
Values Query
To get all the values of a given relationship, supply exactly one query condition with the has value (+
) operator and use the values
parameter.
[[department::+]] | values
Relationships Query
To get all the relationship in use, use the relationships
parameter.
| relationships
To get all the relationships in use for a set of pages matching some condition, specify that condition.
[[department::Web Development]] | relationships
Complex Relationship Queries
Find all pages having the semantic property “employer” with the value “Logos Bible Software”:
[[employer::Logos Bible Software]]
Find all pages having the complex semantic property “employment” with its own property “employer” with the value “Logos Bible Software”:
[[employment::employer::Logos Bible Software]]
Find all pages having the complex semantic property “employment” with its own property “employer” with the value “Logos Bible Software” and that same “employment” property has a “hire date” property value greater than Jan 1, 2000:
[[employment::employer::Logos Bible Software]] [[employment::hire date::>1/1/2000]]
Full-Text Queries
Find pages with an “employer” property and page text containing “software”:
[[employer::+]] [software]
URL Queries
Queries can be passed to the ad-hoc query page via the query
parameter. The colons (::
) must be escaped.
http://examplewiki/query.aspx?query=[[employer%3A%3ALogos Bible Software]]|?hire%20date
JSON Results
The results can be returned as JSON by adding format=json
to the URL.
http://examplewiki/query.aspx?query=[[employer%3A%3ALogos Bible Software]]|?hire%20date&format=json
produces:
{"Results":[{"Page":"John Smith","hire date":"7/1/2006"},{"Page":"Harry Jones","hire date":"8/15/2006"}]}
A callback JavaScript function can be passed with the format
parameter:
http://examplewiki/query.aspx?query=[[employer%3A%3ALogos Bible Software]]|?hire%20date&format=json&callback=processData
produces:
processData({"Results":[{"Page":"John Smith","hire date":"7/1/2006"},{"Page":"Harry Jones","hire date":"8/15/2006"}]})
Feed Results
The results can be returned as an Atom or RSS feed by adding format=atom
or format=rss
to the URL. Any relationships that are part of the result set will be returned as an HTML definition table unless the content
URL query parameter is also provided, in which case the content of the page will be returned in the requested format. Valid content types are: xhtml
, html
and wiki
.
http://examplewiki/query.aspx?query=[[employer%3A%3ALogos Bible Software]]|?hire%20date&format=rss&content=wiki
iCalendar Results
The results can be returned as an iCalendar file or feed by adding format=ics
to the URL. The query must contain one relationship of type date
or one complex relationship event relationship (see below).
http://examplewiki/query.aspx?query=[[employer%3A%3ALogos Bible Software]]|?hire%20date&format=ics
An events is a complex relationship with a relationship named date
of type date
and a relationship named recurrence
. Recurrence can be one of: secondly
, minutely
, hourly
, daily
, weekly
, monthly
or yearly
.
John Smith was born [[birth::date::7/29/1979]].
{{?set birth::recurrence::yearly}}
webcal://examplewiki/query.aspx?query=[[employer%3A%3ALogos Bible Software]]|?birth&format=ics