Query language

The top-logic query language is a set algebra used internally to issue search queries to the abstract database schema. This type of query is only available for code plugins. In configurations and in-app development, onlyTL script is used.

An expression in the query language describes a set of objects via initial sets, set operations, cross product, filter, projection, and partitioning.

Set expressions

A set expression is evaluated without context and returns a set of values.

all(T) The set of all objects that exactly match the object type T.
any(T) The set of all objects that are assignment compatible with the given object type T.
none() The empty set.
setLiteral(Collection) The set of elements in the given collection.
filter(set, expr) The elements of the set set, for which the boolean expression expr evaluates to true.
map(set, expr) The set of results of evaluating the expression expr on all elements of set.
union(set_1, set_2) The union of the sets set_1 and set_2.
intersection(set_1, set_2) The intersection of the sets set_1 and set_2.
substraction(set_1, set_2) The elements of the set set_1, which are not contained in set_2.
crossproduct(a1: set_1, a2: set_2, ..., an: set_n) The cross product of the sets set_1, set_2,... set_n. An entry of the result set is an N-tuple, with names of the entries (a1, a2, ..., an).
partition(set, expr, fun) The set of representatives of an equivalence on the set set. Here, elements a and b from set are equivalent if expr evaluates to the same value in the context of a and b. The function fun returns the representative of the equivalence class by evaluating in the context of the set of all elements of set belonging to an equivalence class.

The set of all objects is all(KnowledgeObject). The set of all association links is all(KnowledgeAssociation). The set of all knowledge base entries is all(KnowledgeItem).

Value Expressions

An expression is evaluated in the context of a scalar value and again returns a scalar value (not a set).

literal(value) The given literal value. The type of the literal is given by the type of the value.
attribute(attr) Value of the primitive row attribute attr of the context object.
reference(name) Access to the reference of the context association with given name (only currently supported names are source and destination).
flex(name) Value of the flexible attribute with name name of the context object.
get(index) Access to the value with given index of the context tuple.
eqBinary(expr_1, expr_2) Comparison of results of evaluations of expressions expr_1 and expr_2 for equality.
eqCi(expr_1, expr_2) Comparison of the results of the evaluations of the expressions expr_1 and expr_2 for string equality without consideration of upper and lower case.
matches(regex, expr) Test whether the result of evaluating expr_1 matches the given regular expression regex.
le(expr_1, expr_2) Comparison of the results v1 and v2 of the evaluations of the expressions expr_1 and expr_2 for v1 less than or equal to v2.
lt(expr_1, expr_2) Comparison of the results v1 and v2 of the evaluations of the expressions expr_1 and expr_2 on v1 true less than v2.
ge(expr_1, expr_2) Comparison of the results v1 and v2 of the evaluations of the expressions expr_1 and expr_2 on v1 greater than or equal to v2.
gt(expr_1, expr_2) Comparison of the results v1 and v2 of the evaluations of the expressions expr_1 and expr_2 on v1 genuinely greater than v2.
inSet(set) Test whether the context object is contained in the set set.
hasType(T) Test whether the context object is exactly of type T.
instanceof(T) Test whether the context object is assignment compatible with the type T.
and(expr_1, expr_2) Boolean AND operation on the results of the evaluations of the expressions expr_1 and expr_2.
or(expr_1, expr_2) Boolean OR operation on the results of the evaluations of the expressions expr_1 and expr_2.
not(expr) Boolean non-linking of the result of the evaluation of the expression expr.
eval(expr_1, expr_2) Evaluation of expr_2 in the context of the result of expr_1.
tuple(expr_1, ..., expr_n) The tuple of values from expr_1 to expr_n.

Functions

A function maps a set of values to a scalar value.

count() Number of elements in the context set.
sum(expr) Sum of the evaluation results of expr on all elements in the context set.
min(expr) Minimum of the evaluation results of expr on all elements of the context set.
max(expr) Maximum of the evaluation results of expr on all elements of the context set.

Order of the result

The result set can be delivered in a specific order. The order is specified by a tuple of order specifications.

order(descending, expr) Primitive order specification. The result is sorted by sorting the results of the evaluation of expr in the context of each result in ascending (descending = false) or descending (descending = true) order.

Equivalences

filter(filter(set, expr_1), expr_2) filter(set, and(expr_1, expr_2))
map(map(set, expr_1), expr_2) map(set, eval(expr_1, expr_2))
inSet(all(T)) hasType(T)
inSet(any(T)) instanceOf(T)