Help:Selection
This is old documentation, see Help:Semantic search -- Skierpage 10:17, 13 March 2008 (CET)
This description applies to the old SMW version 0.7 The behavior is somewhat different in SMW 1.0, which ontoworld.org is running.
Contents |
[edit] Introduction
The ask function selects pages and presents info about them. Between the tags <ask> and </ask> a list of items is put, partly for selection, partly for specifying info to be displayed. The two types of items can be mixed. This page deals with the selection.
Parameters can be entered in the opening <ask> tag. There is one concerning the selection of pages:
- <ask limit=..>
specifies the maximum number of pages selected. It will be capped by 500 anyway.
[edit] Intersection
The selection is the intersection of the sets defined by the selection items. To avoid ambiguity, of adjacent items at least one is put in double square brackets.
A selection item may involve a union of sets, but only in the cases specified below.
[edit] Direct conditions on pages
Two types of sets can be specified:
1. A specific page, e.g.
- <ask>[[Berlin]]</ask> gives <ask>Berlin</ask>
- <ask>[[Talk:Berlin]]</ask> gives "<ask>Talk:Berlin</ask>" although the page Talk:Berlin exists.
Note that the namespace prefixes are not displayed, see the hover box or status bar of the browser, or follow the links.
The full name of a category page denotes the set of pages in the category, while with a colon in front it denotes the category page.
2. A namespace prefix with the colon, followed by "+" indicates the namespace, e.g.
- <ask>[[Help:+]]</ask> gives <ask>Help:+</ask>
- <ask limit=5>[[:+]]</ask> gives <ask limit=5>+</ask>.
- <ask limit=5>[[:Category:+]]</ask> (note the colon in front again) gives the category pages: <ask limit=5>Category:+</ask>, i.e., the categories, including empty ones, but excluding those which have not been created as a page.
For any collection of these sets, we can take the union with "||". E.g.:
<ask>[[Berlin||Help:+]]</ask>
gives
<ask>|Help:+</ask>
[edit] Pages in categories
<ask>[[:+||:Category:+]][[Category:Country in European Union]]</ask>
gives all pages directly or indirectly (through a sub-, subsub-, etc. category) in Category:Country in European Union (including the subcategories themselves):
<ask>|:Category:+</ask>
<ask>[[Category:Country in European Union]]</ask>
gives the same without the subcategories themselves:
<ask></ask>
<ask>[[:Category:+]][[Category:Country in European Union]]</ask>
gives just the sub-, subsub-, etc. categories:
<ask>Category:+</ask>
<ask>[[Category:Country in European Union||Continent]]</ask>
gives all pages directly or indirectly (through a sub-, subsub-, etc. category) in Category:Continent or Category:Country in European Union:
<ask></ask>
A query cannot produce just the pages and subcategories which are directly in a category.
[edit] Conditions with relations
relation::set gives the set of pages with the given relation to any page in the given set ("+" for the set of all pages):
- <ask>[[parent of::Seth]]</ask> gives <ask>Seth</ask>
- <ask>[[parent of::Template:Seth]]</ask> gives <ask>Template:Seth</ask> (the template prefix is ignored)
- <ask limit=5>[[parent of::+]]</ask> gives <ask limit=5>+</ask>.
- <ask limit=5>[[parent of::Help:+]]</ask> gives <ask limit=5>Help:+</ask> (the help prefix is ignored)
For other given sets the nested tags <q> and </q> are needed (restricted to one level):
- <ask limit=5>[[parent of::<q>[[Category:Actor]]</q>]]</ask> gives <ask limit=5>[[parent of::<q></q>]]</ask>.
- <ask limit=5>[[parent of::<q>[[:+]]</q>]]</ask> gives <ask limit=5>[[parent of::<q>+</q>]]</ask> (parents of people with existing pages).
Compare the last example with:
- <ask limit=5>[[parent of::<q>[[+]]</q>]]</ask> gives <ask limit=5>[[parent of::<q>+</q>]]</ask> (all parents, the same as without q-tags).
Within the q-tags we can use any set that does not require inner tags itself, e.g. one involving a relation again:
- <ask limit=5>[[parent of::<q>[[parent of::+]]</q>]]</ask> gives <ask limit=5>+</q>]]</ask> (parents of parents).
[edit] Conditions with attributes
We can check for being defined (:=+), for equality (:=), also for multiple values, and for being less or equal (:=<) and greater or equal (:=>):
- <ask>[[start date:=+]]</ask> gives <ask>The date "+" was not understood.The date "+" was not understood.</ask>
- <ask>[[start date:=2006-10-05]]</ask> gives <ask>2006-10-05</ask>
- <ask>[[start date:=2006-10-05||2006-12-04]]</ask> gives <ask></ask>
- <ask>[[start date:=>2007-01-06]]</ask> gives <ask>The date ">2007-01-06" was not understood.The date ">2007-01-06" was not understood.</ask>
- <ask>[[nr. of screens:=14]]</ask> gives <ask>14</ask>
- <ask>[[nr. of screens:=>13]]</ask> gives <ask>>13">13" cannot be used as a page name in this wiki.</ask>
When needed, automatic unit conversion is applied for the purpose of the test.
If a datatype has no natural linear ordering, inequalities are based on alphabetical order of the normalized datavalues as they are used in the RDF export.
In all cases the result is limited to pages for which the attribute value is defined. However, if the query contains an invalid comparison value, the result is like putting "+", i.e. it gives all these pages:
- <ask>[[nr. of screens:=a]]</ask> gives <ask>a</ask>
- <ask>[[start date:=>2007]]</ask> gives <ask>The date ">2007" was not understood.The date ">2007" was not understood.</ask>
All categories | properties | types
Advice on Annotation | Ask | Attribute name | Browsing and searching | Category | Chains of relations and attributes | Custom units | Namespace | Relation name | Selection | SearchTriple | Sorting | Templates in SMW