Unsupported content

 

This version of the product is no longer supported. However, the documentation is available for your convenience. You will not be able to leave comments.

Search expressions

The full search syntax is supported with a small number of minor modifications for consistency with the rest of the pattern language. The modifications to the search syntax are as follows:

  • Searches have syntax similar to a function call where the expression after the search keyword must be in parentheses.
  • All search keywords must be in lower case.
  • Regular expressions must be matched with the keyword matches rather than like.
  • Identifiers clashing with keywords must be prefixed with $ instead of ~.
  • Post-processing functions must be specified with the single keyword processwith, rather than two separate words process with.

Outside of the pattern language, the search service is backwards-compatible and supports like as a synonym for matches, process with as a synonym for processwith, and accepts keyword escaping with ~ as well as $.

The result of a search expression depends on what kind of show clause it has. If the search has no show clause, the result is a node set; if the search has a show clause with one single attribute shown, the result is a list of values; if the search has a show clause with multiple attributes shown, the result is a list of lists of values. In searches with a processwith clause, the result is either a node set or a list of lists of values, depending on the definition of the post-processing function used.

A search expression has an optional in clause which triggers a refine search, as opposed to a search of the whole datastore. The expression given to in must be a single node or a node set. This example constructs a set of all processes discovered at the same time as the given process, then refines the set:

process := // acquire DiscoveredProcess node from somewhere
all_procs := search(in process
                    traverse Member:List:List:ProcessList
                    traverse List:List:Member:DiscoveredProcess);
required_procs := search(in all_procs where cmd matches "httpd");

Attribute names used in search expressions (except the in clause) are scoped to the search expression, not to the body of the pattern. To access variables in the pattern body, % symbols must be used as in string interpolation:

instance := // instance name from somewhere
db_nodes := search(SoftwareInstance
                   where kind = "Sybase" and
                   instance = %instance%);

Search post-processing functions

A number of search processwith functions are useful for writing patterns that relate items to each other based on observed network connection information. For example, the following example (TPL 1.1 and later) finds all the Software Instances that are communicating with a particular Software Instance:

si := model.SoftwareInstance(key := key details, ...);
communicating := search(in si processwith communicatingSIs)

Was this page helpful? Yes No Submitting... Thank you

Comments