Navigation:  Introduction >

Query Formulation

Previous pageReturn to chapter overviewNext page

This topic explains how to formulate meaningful queries. With the information presented here you will be able to understand how to express your queries using the Semantic Search Engine. To see how to actually create a query using the graphical user interface refer to Creating a query with the graphical interface.

Formulating a simple query

To understand how a query is created we need to examine the various elements that comprise a user query. Every query is represented in the Query panel as a tree consisting of several nodes.

A valid query includes at least 2 nodes:

The root node of the tree, depicted as .
A concept node, depicted as .

To see how we can create the simplest possible query consider the picture below. The query depicted involves a single concept and contains the two nodes mentioned above.

The root node, as can be easily deduced, does not play any particular role in the query and is not editable. The concept node, however, constitutes the foundation upon which the query will expand. For this reason we refer to this node as the query root node as it is essentially the root of the query (but not the root of the tree). The query root node represents a specific concept that we wish to search for. More specifically, we are interested in retrieving objects present in the knowledge base whose type is determined by the concept described in the query root node. In the above example we are interested in retrieving motion capture sequences from the repository.

Adding refinements

Suppose that you executed the query described in the previous section only to realize that the results list is quite long and you are really interested in only a few objects in the list. What you need is obviously to make your query more specific. In other words, to add some constraints to your query to reduce the results list.

If you are an expert in the domain you are searching you might have an idea of what concepts would be involved in refining your query. For example, if you were familiar with motion capture sequences you might be able to come up with some meaningful refinements. Even in this case, however, having all available refinements displayed for your benefit could come quite handy. In the following picture you can see all the available refinements for motion capture sequences as they are displayed in the Query Refinements panel.

The Refinements panel displays all possible refinements that are available for the particular node that is currently selected in the Query tree. To be more precise, the various refinements displayed refer to all the associations of the class represented by the selected node in the Query tree. There are several types of refinements possible depending on what kind of restriction you want to impose on the query.

But what exactly constitutes a refinement? A refinement is applied to a node in the query tree; but a refinement cannot be applied to just every node. The node to be refined must be associated with some concept and in fact, it is this concept that is being refined. Let's see this with a simple example. Consider the refinements shown in the previous picture. These are refinements for the MotionCapureSequence concept. These refinements describe the various properties this concepts has.

There are two different types of properties and their type is defined by the values they accept, as described in section Properties.

Instance-type properties (also called associations or object properties) accept values of type Instance and describe relationships between concepts. Teaches, could describe a relation between concepts Teacher and Lesson.
Data-type properties (also called attributes) accept values from simple data types (such as integer, float, character string, etc.) and represent attributes associated with a concept. Color, brand name, model name and horsepower could represent attributes of the concept Car.

In the Refinements panel object properties are displayed with a icon, while data-type properties with a icon.

An concept association or a concept attribute is not a refinement on its own. It is simply the medium to apply the refinement. Consider the example where we have an association called hasOwner linking the concepts Tool and Person. Suppose we wanted to find tools that have a specific owner with the name "Vincent Cheutet". To translate this to a query we would have to restrict the Tool concept on the hasOwner association with the value "Vincent Cheutet". As descibed in the topic Property Restrictions, this refinement places a Has Value constraint on the object property hasOwner for the concept Tool.

To specify a constraint type for a property shown in the Refinements panel, after having selected a node in the Query panel, you simply right-click on the refinement entry for the property and select a constraint from the popup menu as shown below:

In the same manner you can add more restrictions to better refine your search. You can add as many restrictions as necessary (assuming there are enough properties, of course). As already mentioned, restrictions can be added to any node in the query tree for which there are available refinements. As a general rule, besides the query root, you can add a restriction to any other node for which there is a concept name specified.

All the different types of restrictions that can be imposed on a property for a specific node are displayed below:

SomeValuesFrom restriction on the property implements.

HasValue restriction on the property hasOwner.

Cardinality restriction on the property requiresTool.

Data-type restriction on the property hasExecutionPlatform.

The first two restrictions apply only on object properties ( icon in the Refinements panel). Data-type restrictions apply only on data-type properties ( icon in the Refinements panel), while Cardinality restrictions apply to both object and data-type properties.

It turns out that only SomeValuesFrom restrictions result in nodes specifying a concept name (the Algorithm class in the first restriction above). Therefore, besides the query root, these are the only other nodes (the ones with the icon) which can be refined in the query tree.

To summarize, in order to add a restriction:

1.Click on the node in the query tree you want to refine.
2.If the node can be refined, all available refinements are displayed in the Refinements panel.
3.Right-click on a property in the Refinements panel to refine the query node over that property.
4.Select an appropriate restriction from the popup menu.
5.If the restriction requires it (e.g. Has Value restrictions), specify the required parameters.

Restrictions can also be nested in a query and the nesting can proceed as far as necessary. You should be careful, however, not to create a query that is overly complex and its semantics become unclear. In the following picture you can see a query with nested restrictions:

Boolean combinations

It is possible to use boolean combinations in your queries to add some flexibility or to better specify the semantics, as needed. Boolean combinations represent union, intesection and complement expressions.

A union expression represents the logical disjunction (logical OR) between two terms in the query.
An intersection expression represents the logical conjunction (logical AND) between two terms in the query.
A complement expression represents the logical negation (logical NOT) of a term in the query.

The terms joined by boolean combinations can be simple terms (simple refinements) or complex terms (nested refinements). Furthermore, these combinations can be nested arbitrarily. This means that you can define a boolean combination encompassing other boolean combinations.

To create a boolean combination you use the toolbar placed in the top of the Query panel:

You first click on a node in the query tree and then click on a button in the toolbar. A boolean node will be created surrounding the selected node in the tree. You can accomplish the same by right-clicking on the node in the tree and then selecting the boolean expression from the popup menu:

To add further refinements under the node representing the boolean expression in the tree, you first select that node and then add a refinement from the Refinements panel. The refinements shown when clicking on a boolean node are the refinements associated with the node directly above in the query tree. This is shown in the following picture where the displayed refinements are those of the Task concept in the query root node and not of the SoftwareTool concept which is encapsulated in the intersection term:

To remove a boolean node from the tree, simply right-click on it and select the removal option:

This removes the boolean node from the tree but does not remove any of the terms in its sub-tree. To remove any node in the query tree you first select the node and then click on the Delete button () on the right corner of the toolbar. This, however, removes not only the selected node but its entire sub-tree structure as well.

To see how a query using boolean expressions can be formulated consider the following query:

       Search for tools that either implement some algorithm or do not support any task.

This can be formulated with the following tree expression:

You should note that the absence of any boolean is interpreted as if an intersection term was in place. For example the following query structures are completely equivalent:

Query default node

Each query contains exactly one node which is prefixed by a question mark icon (). This is a special node and specifies the type of the retrieved results; what we are searching for in other words. In most of the examples shown in this guide this node is the query root node (see the first section of this topic). In most cases this is fine and might serve your purpose. But some times it is beneficial or even necessary to specify a different node as the default node for the query.

Consider the following query tree structure:

This query searches for product design tasks which have some algorithm and have a successor task in the chain which is supported by a specific tool (XDef). Suppose that in the same query you are not interested in the tasks which fulfill these criteria, but instead, you are interested in the algorithms associated with the tasks. By specifying as the default node for the query the node associated with the Algorithm concept you can now retrieve the required algorithm objects meeting the criteria of the query.

Only nodes associated with a concept can be specified as defaults for the query. To specify a different node as the default for the query right-click on the node and select "Set node as query default" from the popup menu:

The resulting query tree is shown below:

See also:

Introduction to Ontologies

Property Restrictions