Help:Searching
A simple search will find pages that contain an exact phrase in the text. A semantic search will find pages that have certain attributes.
Contents |
[edit] Simple Search
The quickest way to find information is to look it up directly. On the right-hand side of your screen in the sidebar there is a Search box with two buttons under it labeled "Go" and "Search".
Put your keyword in the searchbox.
- Go - (or Enter on keyboard) will take you automatically to the article, if it exists.
- Search - will search the text of all pages on the wiki (with some restrictions, see below).
If you clicked 'search', or you clicked 'go' and the page you were looking for did not exist, you will be presented with a list of articles that matched your search criteria (or a message that no matches were found).
[edit] How the search works
- Only the article content is searched - the page title is ignored.
- The article content is searched in its raw (wikitext) form - i.e. it searches the text that appears in the edit box when you click 'edit', not the rendered page. This means that content coming from an included template will not be picked up, but the target of piped links will be.
- Even if you enclose a phrase in quotes, the search looks for each word individually. e.g. if you enter "world war 2" it will return pages that contain "world" and "war" and "2".
- The search is not case-sensitive, so "MediaWiki", "mediawiki" and "MEDIAWIKI" all give the same result.
[edit] Restricting the search
If you click the 'Search' button without filling in anything, you will be taken to 'Special:Search' which gives you extra searching options (also available from any search results list)
You may find it useful to restrict a search to pages within a particular namespace e.g. only search within the 'Talk' pages. Tick the namespaces you require for this search.
By default only the namespaces specified in your preferences will be searched. Logged-in users can change their preferences to specify the namespaces they want to search by default.
[edit] Semantic Search
Semantic MediaWiki includes an easy-to-use query language which enables users to access the wiki's knowledge. The syntax of this query language is very similar to the syntax of annotations in Semantic MediaWiki. This query language can be used on the special page Special:Ask or in inline queries.
[edit] Introduction
Queries can be written into the text field of Special:Ask. Among other things, all queries must state some conditions that describe what is asked for. For example, the query:
[[Category:BPAL General Catalog]]
is a query for all pages within the category "BPAL General Catalog", i.e. for all perfumes in Black Phoenix Alchemy Lab's General Catalog. When pressing "Find results" the query will be executed to return results as a simple list of all requested pages. If there are many results, they can be browsed via the navigations links at the top and bottom of the query results, as e.g. in the query for all notes on this wiki.
Much more complex queries are possible, but let us first explain some important things about queries. In general, a query is a request to find a number of pages that satisfy certain requirements. The query must answer two questions:
- Which pages are requested?
- What information should be displayed about those pages?
In the example above, one might be interested in all notes of the requested products. This requires two steps: first find all notes; second print out their names. Both points are now explained independently in the sections below.
[edit] Page selection
In the example above, we gave the single condition [[Category:BPAL General Catalog]] to describe which pages we were interested in. The condition here is exactly what one would otherwise write to assert that some page is in the category BPAL General Notes. The enclosing ask-tags invert its meaning to return all such pages (actually some more; but read on). This is a general scheme: The syntax for asking for pages that satisfy some condition is exactly the syntax for explicitly asserting that this condition holds.
The following queries show what this means:
- [[Category:BPAL General Notes]] gives all pages directly or indirectly (through a sub-, subsub-, etc. category) in the category.
- [[note::Amber]] gives all pages that have an amber note.
- [[available::yes]] gives all pages annotated as being available
By using other categories, relations, or attributes than above, we can already ask for pages which have certain annotations. Next let us combine those requirements:
[[Category:BPAL General Catalog]] [[note::Amber]] [[available::yes]]
asks for everybody who is in the BPAL General Catalog and has the note Amber and is available. In other words: when many conditions are written into one query, the result is narrowed down to those pages that meet all the requirements. Thus we have a logical AND. By the way: queries can also include line-breaks in order to make them more readable. So we could as well write:
[[Category:BPAL General Catalog]] [[note::Amber]] [[available::yes]]
to get the same result as above. Note that queries only return the articles that are positively known to satisfy the required properties: if there is no availability for a product, it will not be selected.
[edit] Wildcards and disjunctions
In the examples above, we gave very concrete conditions, using "BPAL General Catalog", "Amber", and "available" as fillers. It is possible to weaken these conditions in several ways.
Wildcards are written as "+" and allow any filler for a given condition. For example, [[note class::+]] returns all pages that have annotations for the relation "note class", and [[available:=+]] returns all pages that have been assigned an availability. For categories, this feature makes little sense: [[Category:+]] just returns everything that has some category.
Disjunctions are written as "||" and allow queries to require (at least) one out of several possible fillers. For example, [[Category:BPAL General Catalog||The Salon]] retrieves everything that is in the Category:BPAL General Catalog or Category:The Salon. This also includes everything that is both (a logical OR ). We can also specify a list of pages as relation target, e.g. [[note::patchouli||musk]] and a list of attribute values.
[edit] Subqueries
To ask for pages having a particular relation to any page in a more complex set, the latter can be written in the form of a query. In this case, instead of a concrete (list of) page names, one enters a new query enclosed in <q> and </q>. For instance, one can ask for all BPAL perfumes that have a type of fruit in them:
[[Category:BPAL General Catalog]] [[note::<q>[[Category:Fruit]]</q>]]
Arbitrary levels of nesting are possible.
[edit] Asking for categories
Conditions with categories are generally simple, but they are more powerful than they might at first appear:
When searching for pages within a category, the result also involves all pages that are contained in subcategories of this category.
For example, the category "Sin and Salvation" is a subcategory of "BPAL General Catalog". Then the query [[Category:BPAL General Catalog]] will also return the perfumes that are in the category "Sin and Salvation" only. This makes sense in many situations, but you can still view the pages that were directly put into the category Sin and Salvation by just going to the page of that category (by following the link Category:Sin and Salvation).
[edit] Direct conditions on pages
So far, all conditions depended on some or the other annotation given within an page. But there are also conditions that directly select some pages, or pages from a given namespace.
By directly giving some pagename (possibly including a namespace prefix), or a list of such pagenames separated by ||, the existing pages with those names are selected, e.g.
[[Amber||Patchouli||Relation:Note]]
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 specific questions about a set of scents. But direct selection of articles is most useful if further properties of those articles are asked for, as is described below.
In the case of categories, it is necessary (as known from normal pages) to put a ":" before the page name to prevent confusion of the conditions [[Category:BPAL General Catalog]] (return all BPAL General Catalog pages) and [[:Category:BPAL General Catalog]] (return the category "BPAL General Catalog").
A less strict way of selecting given pages is via namespaces. This is done by using wildcards in the selected pages, e.g. by writing
[[Help:+]]
to return every page in the "Help" namespace. Since the main namespace usually has no prefix, one must write [[:+]]. In the case of categories, an additional ":" is again needed in front of the namespace label to prevent confusion.
[edit] Data to be displayed
Simple queries using conditions as above will merely return a list of pages. To display properties of these pages, one adds statements such as [[available:=*]] to show the availability (if any) of the selected pages. Using "*" as a filler indicates that this code does not specify a condition for the selection of pages, but specifies what should be displayed about the selected pages. Thus, we can also write
- [[inspiration::*]] to show all pages that have a "inspiration" relation to the result page,
- [[Category:*]] to show all categories that the result page has directly been stated to be in.
Even if there are no "inspiration" relations for a page, the page is still in the selection, and an empty field will be printed. Likewise, if some article has been assigned many different values for one property, all of them will be displayed.
[edit] Sorting results
Special:Ask has a special field for ordering results according to some attribute. This requires all selected pages to have a value for this attribute, and thus the query must impose this additional restriction. For example, in order to sort the perfumes in this wiki by company, the following is needed:
- the query should be [[product::perfume]] [[company::+]]
- in an ask statement, specify the column to be sorted by the sort condition: |sort=company
- using the Special:Ask-page, just use the input field "sort by column" instead - like here: view results
- Ascending or descending order can be chosen by specifying
|order=ascendingin the same way or by clicking the little sorter-icons in the header of a results-table.
At the moment, the condition [[company::+]] is crucial for this to work.
[edit] Using templates and variables
Within a query, arbitrary templates and variables can be used. This can be used to create a standard query that displays all future events (where "future" gets its meaning from the current date):
[[Category:BPAL General Catalog]]
[[release date:=>{{CURRENTYEAR}}-{{CURRENTMONTH}}-{{CURRENTDAY}}]]
Many other uses are possible, especially when using queries inline. However, it is in no case possible to use template parameters (the things in {{{ }}}) within a query. Sorry.
Another very useful variable for inline queries is {{PAGENAME}} which allows you to customize a query that is used unchanged on many pages. Read about inline queries for more information.
