Single page restriction

From semantic-mediawiki.org

This section describes how to directly select some pages, or pages from a given namespace.

Giving that the page title is known (possibly including a namespace prefix), as list separated by ||, the Query Engine will match pages with those names. An example is the query

[[Brazil||France||User:John Doe]]

which has three results (at least if the pages exist). Note that the result does not display any namespace prefixes; see the hover box or status bar of the browser, or follow the links to determine the namespace.

Restricting the set based on an attribute value, one could ask, e.g., «Who of Bill Murray, Dan Aykroyd, Harold Ramis and Ernie Hudson is taller than 6ft?». But direct selection of articles is most useful if further properties of those articles are asked for, e.g. to simply print the height of Bill Murray.

Categories[edit]

To select a category in this way, a : must be put before the category name. This avoids confusing [[Category:Actor]] (return all actors) and [[:Category:Actor]] (return the category «Actor»).

LIKE and NOT LIKE operators[edit]

The following may work differently if you have Full-Text Search enabled on your wiki.

Starting with Semantic MediaWiki 2.4.0 it is possible to use the like "~" and not like "!~" comparators to describe single pages.1 An example is the following query

[[~John*]]

This would return all wiki pages as well property values of data type Page starting with "John", e. g. "John Doe", "John Lackland", etc. It can be used in conjunction with other query elements such as properties, inverse properties, concepts and categories.

For example, if you have a property "Has user" (type Page) and want to retrieve a list of all values that begin with the letter B, you could use the follow query:

[[-Has user::+]] [[~B*]]

See <sandbox.semantic-mediawiki.org> for a live example.

References

  1. ^  |  Semantic MediaWiki: GitHub pull request gh:smw:1246