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 ~{{/code}}.
    * 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 {{code language="none"}}${{/code}}.

    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:

    {{code language="none"}}process := // acquire DiscoveredProcess node from somewhere{{/code}}
    ##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:

    {{code language="none"}}instance := // instance name from somewhere{{/code}}
    ##db_nodes := **search**(SoftwareInstance##
    ##                   **where** kind = "Sybase" **and**##
    {{code language="none"}}                   instance = %instance%);{{/code}}

    {{id name="Searchexpressions-SquareBracketSearch"/}}You can also use [[search (% style="color: rgb(23,43,77);" %)square bracket limit and flag syntax>>doc:IT-Operations-Management.Discovery.BMC-Discovery.DISCO231.Using.Using-the-Search-and-Reporting-service.Using-the-Query-Language.Search-Flags-and-limits.WebHome]] in TPL search expressions (from TPL 1.21). For more information on the search service usage of limits and flags, see [[Search Flags and limits>>doc:IT-Operations-Management.Discovery.BMC-Discovery.DISCO231.Using.Using-the-Search-and-Reporting-service.Using-the-Query-Language.Search-Flags-and-limits.WebHome]]. For example:

    ##hosts := **search**([5, include_destroyed] Host##
    ##                   **where** os = "Windows")##{{code language="none"}};{{/code}}

    == {{id name="Searchexpressions-Searchpost-processingfunctions"/}}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)##

    \\

    \\

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*