Show TOC

Background documentationSearch Tree Expression

 

The search tree expression is a non-binary tree structure with conditions and results. It is used for assigning different business-relevant conditions to different tree branches. The system checks the input and compares it to the conditions defined for each node. Search tree nodes have always a condition assigned, and they can have a result assigned. A condition has to be assigned to each node, except for the root node. A node can have several child nodes or subnodes. All the subnodes in one level (that is, with the same parent node) are called sibling nodes. A node without any subnodes assigned is called leaf node.

The search tree searches in a top-down approach, according to the rules of the selected match mode. If the condition assigned to a search tree node is evaluated as true and the expression is in First Match or Multiple Match mode, the expression returns the result assigned to the current node.

In Multiple Match mode, the rule evaluation then branches down to the lower subnode and continues the search in a similar fashion. If the condition node returns false then the search jumps to the next sibling node from left to right. It continues with the search in this node and its subnodes.

Note Note

Due to the sequential processing order of the search tree expression, it is necessary to clearly analyze the use case that you want to model with the search tree and distribute the conditions properly over the tree nodes. Otherwise, it might happen that a particular combination of conditions is never tested because of its position inside the tree structure — even if that combination would result in a match of higher quality.

End of the note.

Features

Mode of Operation

You can decide whether the search tree shall yield a result data object upon an input value matching a node condition, or whether an action shall be triggered.

Match Mode

The search tree expression supports different modes of operation to control the way how the expression processes a given input value and decides whether a particular value is matched by one of the tree nodes. You can choose between the following match modes:

  • First Match: In First Match mode, the search proceeds until the first node whose condition matches the input value and returns the corresponding result, if there is one assigned to that node. Any further processing down the tree is stopped.

  • Multiple Match: In Multiple Match mode, the search is carried out across the entire tree (all levels, all branches). All result values assigned to nodes whose conditions are evaluated as true are collected during the search and stored in the expression's result data object. If the condition of a node is evaluated as false, processing continues with the next sibling of the parent node or the next yet unprocessed branch. This goes on either until the tree has been completely processed or until a node in the last branch is evaluated as false.

    Note Note

    In Multiple Match mode, the result data object must be of type table.

    End of the note.
  • Qualified Match: In Qualified Match mode, an input value is tested against a chain of semantically independent conditions associated to the different tree nodes. As opposed to First Match mode, processing does not stop at the first matching node but continues until a node condition is not met. An input that satisfies best the different conditions in a particular search tree branch is referred to as a qualified match. The result assigned to the last node of the matching branch is returned as the expression's result data object.

More Information on Qualified Match Mode

In contrast to many other tree constructs, climbing down the search tree branches does not necessarily mean to start with a general condition which would then be refined with each level of the tree (for example, "region = EMEA" -> "subregion = Eastern Europe" -> "member of European Community = yes" -> "country = Poland"). Rather, each level can have a condition assigned which is semantically completely independent from the condition on the previous level (e.g., "region = EMEA" -> "industry = banking" -> "revenue >= 50 billion Euro" -> "is listed at NYSE" etc.; but this path could as well be defined in reverse order, starting with the NYSE listing and finishing with EMEA - this only depends on the nature of the business case to be modeled).

Drilling down through such lists of conditions stops at a point where a condition is not met anymore. Once the evaluation has reached this point, it is correct to say that the current input matches all the different previous conditions up to this point. The expression then returns the result value (or trigger the action) associated to the last matching node as a qualified match.

Additional Settings
Context Data Object

In contrast to most other expression types, the search tree expression does not have one central context data object. Rather, each single node of the tree can have a different data object or expression assigned which is used as input value to be tested against the node condition.

Result Data Object

For the result data object of a search tree expression, the following rules apply:

  • You have to make sure that all result values used in the tree are type-compatible with the result data object so that the node result can be properly assigned to the result data object.

  • In Multiple Match mode, the result data object must be a table data object because in this mode, the result is typically a list of values.

  • If the search tree expression is defined to trigger an action rather than returning a result value, the result data object is automatically set to the predefined Actions table.

Result Only at Leaf

With this flag set, the search tree expression only yields a result if all the conditions in a complete tree branch from the root node down to one of the leaf nodes (with no further subnodes) are satisfied. Setting this flag has the following consequences regarding the assignment of results to the nodes of the tree:

  • Nodes that have subnodes must not have a result assigned.

  • Leaf nodes with no further subnodes must have a result assigned.

Return Initial Value If No Match Is Found

With this flag set, the search tree expression returns the initial value defined for the type of the result data object if none of the conditions defined in the tree matches the input value. Otherwise, the rule evaluation stops and an exception is raised.

Note Note

If you decide to use this option, be very careful that you can make a clear distinction between a well-defined result value that was returned by a node with a matching condition and the type-specific initial value that was returned as the result of an unsuccessful rule evaluation. For example, if the result data object of a search tree expression is a data object of type number, you should make sure that none of the tree nodes carrying a result has the value 0 assigned because for the system it would be impossible to decide if this is meant as a valid numeric value or as an indicator for a failed rule evaluation.

End of the note.