- Introduction to Semantic MediaWiki
- Browsing and searching
- Semantic search
- Selecting pages
- Displaying information
- Result formats
- Inline queries
- Semantic Web
|Found errors or typos? Just edit the page or leave a message on the talk page.|
The English language documentation is canonical and most up to date.
Unions (OR) of results
Disjunctions are OR-conditions that admit several alternative conditions on query results. A disjunction requires that at least one (but maybe more than one) of the possible alternatives is satisfied (logical OR).
SMW has two ways of writing disjunctions in queries:
- The operator OR is used for taking the union of two queries.
- The operator || is used for disjunctions in property values, page names and category names.
For example, a query that describes pages of actors in
[[Category:Musical actor]] or
[[Category:Theatre actor]], or in both of them, can be written as:
[[Category:Musical actor]] OR [[Category:Theatre actor]]
- or more concisely,
[[Category:Musical actor||Theatre actor]]
Similarly, a query that describes all pages of people born in Boston or New York can be written using one of these operators:
[[born in::Boston]] OR [[born in::New York]]
- or again more concisely,
[[born in::Boston||New York]]
Note that || does not always offer an alternative to OR. For example,
[[born in::Boston]] OR [[Category:Actor]]
- cannot be expressed with ||.
OR operates on the query, not on a single element of the query. Thus in the following query, which is intended to list actors born in Boston or in New York, the category name needs to be repeated:
[[Category:Actor]] [[born in::Boston]] OR [[Category:Actor]] [[born in::New York]]
To combine multiple queries, you can also use the extension Semantic Compound Queries.