Pentru a putea vota, modifica pagini sau abona la modificările unei pagini trebuie să fiți autentificați. Cu această ocazie scăpați și de acest mesaj deranjant.

Ajutor:What can i do with the query interface?

De la
Salt la: navigare, căutare
Question:=What can i do with the query interface?
description:=Use the QI to search the wiki, generate useful lists and tables containing facts from the knowledgebase.

Overview of the query interface

The query interface is a special page and can therefore be accessed on the page “Special:Specialpages”. When accessing this page, you can see the Query Interface (QI) in its initial state.

Initial view of the query interface

On the very bottom, there is the menu bar with the three main functions:

  • Preview query: A full preview of the current query, also considering the layout settings on bottom
  • Copy to clipboard: This button will copy the ask query to the clipboard. This will always work for Microsoft Internet Explorer Browsers. If you use Firefox, there might be a security question coming up. Depending on your local security settings, the “copy to clipboard” functionality will not be available at all.
  • Reset Query: This button will reset the current query and all its sub- and superqueries

On top of the query interface to the left, you can see the query tree with a breadcrumbs navigation and the tree graph. The breadcrumbs navigation shows where you are in the structure of your current query. The tree shows the structure of the query and allows you to navigate through it by clicking the single items.

Query Tree of the main part of the query
Query tree of a subquery

In the middle of the QI, there is the main part of the interface where you can add further restrictions to your query. Right niext to this area, the context sensitive help is shown. For further information about context sensitive help, see Help:What_is_context_sensitive_help? Below the main area, you can see the table column preview. Most query results in SMW are shown in tables. This little window will give you an instant preview of which columns will appear in the result table of the current query. At the bottom, there is the query layout manager (QLM). The QLM supports you by defining the output format of your query, since there are many different possibilities.

Creating a sample query with the QI

This section of the user documentation will give a step by step example for creating a query with the QI. The example query used in this case is as follows:

“Give me the number of inhabitants for every European Union capital”

First of all, we have to define what we look for and according to this choose a category. Of course, this choice always depends on the content and structure of the wiki. In this example, we will say that capitals are in the category “city”. The first step therefore is that we ask for this category. In every input field of the QI you can use auto completion in order to find appropriate inputs.

Step 1: Add category

After clicking “OK”, the category will appear in the query tree. For every capital, we want to have the number of inhabitants, which is a property. The next step therefore is to add this property to the query.

Step 2: Add property

As we would like to have the number of inhabitants printed out in the result table, we have to check “Show in result table”. Please be reminded that only properties in the main part of the query can be printed. Properties of subqueries can not be printed, therefore this checkbox will not appear. As value we enter “*” for all values, but this field can as well stay empty which would have the same effect.

As stated in our query, we want only those cities that are capitals of countries which belong to the European Union. The word “which” is always a hint on a subquery. Therefore we have to create a subquery here.

Step 3: Add property with subquery

To add a subquery, simple check the “Insert subquery” box next to the input field. Subqueries are only possible with properties that refer to another wiki page. If a property has for example Integer or Date as a type, subqueries are not possible.

Step 4: Query tree of the main query

Now, the subquery can be edited. This happens by clicking “Subquery 1” in the tree view. You will then see a new empty tree which represents the contents of the subquery. This subquery will search for all Countries that are part of the European Union. Therefore, we will have to add the category “Country” and the property “is part of” with the value “European Union”.

Step 5: Query tree of a subquery

By clicking on “Main” on top of the treeview, you can navigate back to the main part of the query. Before finishing the query, some layout parameters will be set. As a format, we choose table. The main label is the heading of the first table column. We will call this one city. Finally, we want our results sorted by the number of inhabitants in an descending order.

Step 6: Query Interface with the final query

By clicking on “Preview results”, the results of the current query can be checked. In this case, there are only two cities in the database which are Berlin and Rome. The query is now finished and can be copied to the clipboard for further use in other articles.

Step 7: Preview of query results

The query layout manager

This section will give a short overview of the query layout manager and the meaning of the single options.

Layout option Allowed values What it does
Format Table, bullet list, numbered list, list, count, timeline Defines the output format of the query. Count means that only the number of results is displayed
Sort by All columns that are shown in the result Defines which column of the result table should be used to sort the results
Order Ascending, descending Ascending or descending order
Link Subject, all, none Defines which parts of the result should be linked. Subject means only the first column is linked to the corresponding article.
Limit Number The maximum number of results shown. If there are more results, a link for a full result list will be provided automatically
Headers Show, don’t show Defines if the headers of the table are shown
Intro Text Text that appears before the results are displayed
Mainlabel Text Label of the first column of the result table
Default Text Text that will appear if there are no results

Advanced usage: conjunction and disjunction

Whenever you add a category, instance or property they are connected by conjunction. This means that all entered restrictions have to be true in order to appear in the result table. However, sometimes it is necessary to use a disjunction. This can be done by using the green plus sign next to an input field.

Using disjunction on a category

The above image shows an example of disjunction. This query would return all articles that are either in the category book OR in the category movie. If you add one category Movie and one category book, conjunction is applied and the query would return only articles that are in both categories (for example “1984” by George Orwell, since this is a book as well as a movie).