NODECOUNT Expressions
Sometimes it is useful to filter, sort, or show the number of nodes related to each node in the set. This is achieved with a NODECOUNT
expression. It behaves like a function, except that its arguments are a traversal clause. To show the number of dependencies of each Business Application Instance:
SEARCH BusinessApplicationInstance SHOW name, NODECOUNT(TRAVERSE DependedUpon:Dependency: Dependant:BusinessApplicationInstance)
NODECOUNT
accepts all the traversal expressions described in the previous section, including chaining and where clauses.
NODECOUNT
is the correct way to filter based on properties of related nodes, rather than using a key expression in a WHERE
clause. The following is a way to find all Linux Hosts running products from the Apache foundation, for example:
SEARCH Host WHERE os_type HAS SUBWORD "linux" AND NODECOUNT(TRAVERSE Host:HostedSoftware:RunningSoftware:SoftwareInstance WHERE type HAS SUBWORD "apache")
Similar to NODECOUNT
, the NODES
keyword performs a traversal and returns a list of the traversed-to nodes. It is only used for internal purposes since, in general, lists of nodes cannot be handled in the search service.
Comments
Log in or register to comment.