The select clause

The select clause defines the extraction criteria that will be used to select the records that will be returned by a query. In your query, you can use data fields or technical fields. You can write a simple select clause or use elements such as glob patterns or field modifiers.

For more information about records, see What is a record.

The data fields are present in the Wazi Deploy evidence files. They can be, for example, the name of an activity or an action, or the name or type of an artifact. The data fields are listed and explained in The evidence file.

How to specify a simple select clause

If you want to list all the records, enter the following code:
select: all

If you want to filter the records, then you must specify the values of the fields that you want to search for.

The following examples show how you can enter a simple select clause on data fields:
  • Selection of all the records that have a name field whose value is MEMBER_COPY:
    select:
      name: MEMBER_COPY
  • Selection of all the records that have a steps field for which a subrecord contains a name field whose value is MEMBER_COPY:
    select:
      steps:
        name: MEMBER_COPY
  • Selection of all the records that have both a name field and a steps field. The value of the name field must be ADD and the steps field must contain a subrecord that contains a name field whose value is MEMBER_COPY:
    select:
      name: ADD
      steps:
        name: MEMBER_COPY

Using glob patterns in the select clause

You can use glob patterns to search for fields whose value matches the pattern that you specify.

You can enter a glob pattern in the key name or in the key value. The most common use is in the key value.

The following table lists and explains the glob patterns. It is followed by examples that show you how to use some of them.
Glob patterns Explanations
* Matches any sequence of characters, including an empty sequence.
? Matches a single character.
[abc] Matches one of the characters (such as abc) that are entered in the square brackets.
[^abc] Matches any character, except the characters that are entered in the square brackets.
[0-9] or [A-F] Matches any character in the given interval.
The following examples show how you can select records by using glob patterns on data fields:
  • Selection of the records whose name field starts with LG:
    select: 
      name: LG*
  • Selection of the records whose name field starts with N, R, or T:
    select:
      name: '[NRT]*'
  • Selection of the records whose name field contains an uppercase A:
    select:
      name: '*A*'

Using field modifiers in the select clause

You can use field modifiers to indicate to what extent each criterion of the select clause applies.

You can enter the field modifiers after the key name. The use of a white space before or after the field modifier is optional.

You can combine the field modifiers.

The following table lists and explains the field modifiers. It is followed by examples that show you how to use some of them.
Field modifiers Explanations
>= The field value must be greater than or equal to the specified value.
> The field value must be strictly greater than the specified value.
<= The field value must be less than or equal to the specified value.
< The field value must be strictly less than the specified value.
! The field value must match a value different from the specified value.
| The field value must match at least one of the specified values.
& or no field modifier The field value must match all the specified values.
~ The field value must match the specified regular expression.
The following examples show how you can select records by using field modifiers on data fields:
  • Selection of the records whose name must be lexicographically greater than or equal to LGD and strictly lower than LGU:
    select:
      name>=: LGD  
      name<: LGU
  • Selection of the records whose name is not CICS:
    select:
      name!: CICS 
  • Selection of the records whose name lists either CICS or DB2:
    select:
      name|:
      - CICS 
      - DB2 
  • Selection of the records whose properties has at least two subrecords. One subrecord must have a path key and another subrecord must have a type key.
    select:
      properties&:
      - key: path 
      - key: type 
    Note: The & is optional. You can omit it to specify the same selection.
  • Selection of the records whose name ends with an uppercase E. In the following example, you use a regular expression for this selection:
    select:
      name~: .*E$
    Note: The regular expressions are a standard concept that is not specific to Wazi Deploy.

Combining selection criteria in the select clause

You can combine selection criteria with the following keywords: and, or, all, any, none, not.
Note: The and, or, all, any, and none keywords must contain a YAML list.
The following examples show how you can combine selection criteria on data fields:
  • Selection of the records that do not meet the following criteria: a key that is either path or type and a value that starts with an uppercase C.
    select:
      not:
        and:
        - or:
          - key: path
          - key: type
        - value: C*
  • Selection of the records that do not have a key that is either path or type and do not have a value that starts with an uppercase C.
    select:
      none:
      - key: path
      - key: type
      - value: C*

Using technical fields in a select clause

The previous explanations and example were based on data fields.

You must be aware that you can also use technical fields, which are automatically added to each record at indexing time.

The names of the technical fields start with ymli_ (which stands for YAML Indexer) but alternate names can be defined in an alias file.

The following table lists and describes the names of the technical fields that you can use in the select clause.
Field names Description
ymli_id Unique numeric identifier of a record. Each record has one id.
ymli_file Name of the file, without the folder name, that the record was extracted from.
ymli_folder Path to the folder that contains an indexed file. The path is relative to the index root.
ymli_level Level of the record relatively to the root in the YAML tree.
ymli_category Path from the root of the YAML tree to the record.
ymli_parent Reference to an ancestor record.
ymli_parent_id Identifier (ymli_id) of the parent record.
ymli_rank Rank of the record in the current file.
ymli_line Start line of the record in the indexed file.
ymli_stop_line End line of the record in the indexed file.
ymli_version Version of the record. It corresponds to the rank of the indexing that produced this record.
The following examples show how you can use technical fields in the select clause:
  • Selection of the indexed records that are in a file whose name contains Python or python:
    select:
      ymli_file: '*[Pp]ython*'
  • Selection of all the artifacts that start with L. If you look at an evidence file, you can see that an activity node contains actions nodes, which in turn contain steps nodes, which in turn contain artifacts nodes. With the ymli_category field, you can make queries that are related to this hierarchy. In this example, you use a regular expression.
    select:
      ymli_category~: ^ activities(:[0-9]+)? actions(:[0-9]+)? steps(:[0-9]+)? artifacts(:[0-9]+)? $
      name: L*
  • Selection of all the records that are on the fourth level of the YAML hierarchy:
    select:
      ymli_level: 4