# Matchers

The valid matchers you can use in a [condition](/rules-engine/conditions.md) or [aggregation](/rules-engine/conditions.md#aggregations) depend on the type of field on which you want to check the condition or perform the aggregation (e.g. you cannot check if a string such as a tag or an SKU code is greater than another). [Some matchers](#value-required) (e.g. `eq`, `gteq`, et.) require a value to be compared against, [some others](#value-not-required) (e.g. `null`, `present`, etc.) don't.&#x20;

{% hint style="warning" %}
For the comparison to work, the provided value must be of the correct type (e.g. you cannot check if a string such as a tag or an SKU code is equal to a number).&#x20;
{% endhint %}

## Value required

You can find here below the complete list of the available matchers the require a value to be defined in the related [condition](/rules-engine/conditions.md) in order to work:

<table><thead><tr><th width="170">Matcher</th><th width="135">Field type<select multiple><option value="oBHsH7qDg2tw" label="String" color="blue"></option><option value="NZyTg5ZzemVm" label="Integer" color="blue"></option><option value="mXKZ7rgJXazm" label="Boolean" color="blue"></option><option value="nq5rXw8hk0XZ" label="Array" color="blue"></option><option value="Aj81tlNYPIit" label="Datetime" color="blue"></option><option value="eNzAXjyu1qyb" label="Float" color="blue"></option><option value="P6Vq9KtPBnkI" label="Object" color="blue"></option></select></th><th width="123">Value type<select multiple><option value="77odCAkbI0hY" label="String" color="blue"></option><option value="84LAYBuqLP7v" label="Array" color="blue"></option><option value="DWzlMz1ZT5T5" label="Integer" color="blue"></option><option value="5uuR4n3RGNBA" label="Boolean" color="blue"></option><option value="vLL3YURz6nQU" label="Datetime" color="blue"></option><option value="S9nSF6HUr3Hr" label="Float" color="blue"></option><option value="LiFhijJkvgjJ" label="Object" color="blue"></option></select></th><th>Description</th></tr></thead><tbody><tr><td><strong><code>eq</code></strong></td><td><span data-option="NZyTg5ZzemVm">Integer, </span><span data-option="oBHsH7qDg2tw">String, </span><span data-option="Aj81tlNYPIit">Datetime, </span><span data-option="mXKZ7rgJXazm">Boolean</span></td><td><span data-option="DWzlMz1ZT5T5">Integer, </span><span data-option="77odCAkbI0hY">String, </span><span data-option="vLL3YURz6nQU">Datetime, </span><span data-option="5uuR4n3RGNBA">Boolean</span></td><td>Matches if the <code>field</code> value is equal to the provided <code>value</code>.</td></tr><tr><td><strong><code>not_eq</code></strong></td><td><span data-option="NZyTg5ZzemVm">Integer, </span><span data-option="oBHsH7qDg2tw">String, </span><span data-option="Aj81tlNYPIit">Datetime, </span><span data-option="mXKZ7rgJXazm">Boolean</span></td><td><span data-option="DWzlMz1ZT5T5">Integer, </span><span data-option="77odCAkbI0hY">String, </span><span data-option="vLL3YURz6nQU">Datetime, </span><span data-option="5uuR4n3RGNBA">Boolean</span></td><td>Matches if the <code>field</code> value is not equal to the provided <code>value</code>, not including null values.</td></tr><tr><td><strong><code>lt</code></strong></td><td><span data-option="NZyTg5ZzemVm">Integer, </span><span data-option="Aj81tlNYPIit">Datetime</span></td><td><span data-option="DWzlMz1ZT5T5">Integer, </span><span data-option="vLL3YURz6nQU">Datetime</span></td><td>Matches if the <code>field</code> value is less than the provided <code>value</code>.</td></tr><tr><td><strong><code>lteq</code></strong></td><td><span data-option="NZyTg5ZzemVm">Integer, </span><span data-option="Aj81tlNYPIit">Datetime</span></td><td><span data-option="DWzlMz1ZT5T5">Integer, </span><span data-option="vLL3YURz6nQU">Datetime</span></td><td>Matches if the <code>field</code> value is less than or equal to the provided <code>value</code>.</td></tr><tr><td><strong><code>gt</code></strong></td><td><span data-option="NZyTg5ZzemVm">Integer, </span><span data-option="Aj81tlNYPIit">Datetime</span></td><td><span data-option="DWzlMz1ZT5T5">Integer, </span><span data-option="vLL3YURz6nQU">Datetime</span></td><td>Matches if the <code>field</code> value is greater than the provided <code>value</code>.</td></tr><tr><td><strong><code>gteq</code></strong></td><td><span data-option="NZyTg5ZzemVm">Integer, </span><span data-option="Aj81tlNYPIit">Datetime</span></td><td><span data-option="DWzlMz1ZT5T5">Integer, </span><span data-option="vLL3YURz6nQU">Datetime</span></td><td>Matches if the <code>field</code> value is greater than or equal to the provided <code>value</code>.</td></tr><tr><td><strong><code>multiple</code></strong></td><td><span data-option="NZyTg5ZzemVm">Integer</span></td><td><span data-option="DWzlMz1ZT5T5">Integer</span></td><td>Matches if the <code>field</code> value is a multiple of the provided <code>value</code> (i.e it can be divided by the provided value without a remainder).</td></tr><tr><td><strong><code>matches</code></strong></td><td><span data-option="oBHsH7qDg2tw">String</span></td><td><span data-option="77odCAkbI0hY">String</span></td><td>Matches if the <code>field</code> value matches the pattern in the provided <code>value</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions">regular expression</a>.</td></tr><tr><td><strong><code>does_not_match</code></strong></td><td><span data-option="oBHsH7qDg2tw">String</span></td><td><span data-option="77odCAkbI0hY">String</span></td><td>Matches if the <code>field</code> value does not match the pattern in the provided <code>value</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions">regular expression</a>.</td></tr><tr><td><strong><code>start_with</code></strong></td><td><span data-option="oBHsH7qDg2tw">String</span></td><td><span data-option="77odCAkbI0hY">String</span></td><td>Matches if the <code>field</code> value starts with the provided <code>value</code>.</td></tr><tr><td><strong><code>not_start_with</code></strong></td><td><span data-option="oBHsH7qDg2tw">String</span></td><td><span data-option="77odCAkbI0hY">String</span></td><td>Matches if the <code>field</code> value does not start with the provided <code>value</code>.</td></tr><tr><td><strong><code>end_with</code></strong></td><td><span data-option="oBHsH7qDg2tw">String</span></td><td><span data-option="77odCAkbI0hY">String</span></td><td>Matches if the <code>field</code> value ends with the provided <code>value</code>.</td></tr><tr><td><strong><code>not_end_with</code></strong></td><td><span data-option="oBHsH7qDg2tw">String</span></td><td><span data-option="77odCAkbI0hY">String</span></td><td>Matches if the <code>field</code> value does not end with the provided <code>value</code>.</td></tr><tr><td><strong><code>gt_lt</code></strong></td><td><span data-option="NZyTg5ZzemVm">Integer, </span><span data-option="Aj81tlNYPIit">Datetime</span></td><td><span data-option="84LAYBuqLP7v">Array</span></td><td>Matches if the <code>field</code> value is greater than the first value of the provided <code>value</code> array and lower than the second.</td></tr><tr><td><strong><code>gteq_lt</code></strong></td><td><span data-option="NZyTg5ZzemVm">Integer, </span><span data-option="Aj81tlNYPIit">Datetime</span></td><td><span data-option="84LAYBuqLP7v">Array</span></td><td>Matches if the <code>field</code> value is greater than or equal to the first value of the provided <code>value</code> array and lower than the second.</td></tr><tr><td><strong><code>gt_lteq</code></strong></td><td><span data-option="NZyTg5ZzemVm">Integer, </span><span data-option="Aj81tlNYPIit">Datetime</span></td><td><span data-option="84LAYBuqLP7v">Array</span></td><td>Matches if the <code>field</code> value is greater than the first value of the provided <code>value</code> array and lower than or equal to the second.</td></tr><tr><td><strong><code>gteq_lteq</code></strong></td><td><span data-option="NZyTg5ZzemVm">Integer, </span><span data-option="Aj81tlNYPIit">Datetime</span></td><td><span data-option="84LAYBuqLP7v">Array</span></td><td>Matches if the <code>field</code> value is greater than or equal to the first value of the provided <code>value</code> array and lower than or equal to the second.</td></tr><tr><td><strong><code>is_in</code></strong></td><td><span data-option="NZyTg5ZzemVm">Integer, </span><span data-option="oBHsH7qDg2tw">String, </span><span data-option="Aj81tlNYPIit">Datetime</span></td><td><span data-option="84LAYBuqLP7v">Array</span></td><td>Matches if the <code>field</code> value is included in the provided <code>value</code> array.</td></tr><tr><td><strong><code>is_not_in</code></strong></td><td><span data-option="NZyTg5ZzemVm">Integer, </span><span data-option="oBHsH7qDg2tw">String, </span><span data-option="Aj81tlNYPIit">Datetime</span></td><td><span data-option="84LAYBuqLP7v">Array</span></td><td>Matches if the <code>field</code> value is not included in the provided <code>value</code> array.</td></tr><tr><td><strong><code>array_match</code></strong></td><td><span data-option="nq5rXw8hk0XZ">Array</span></td><td><span data-option="LiFhijJkvgjJ">Object</span></td><td>Matches if the <code>field</code> array meets all the requirements specified within the <code>value</code> object (learn more <a href="#array-match">here</a>).</td></tr></tbody></table>

### Array match

When the `field` value is an array, the `array_match` matcher enables you to check multiple inclusion/exclusion conditions on different arrays provided within the `value` object using the following additional operators:

<table><thead><tr><th width="172">Operator</th><th width="136">Type<select><option value="HGwxtKfDFd8j" label="String" color="blue"></option><option value="01t2Zj6y6nA6" label="Array" color="blue"></option></select></th><th></th></tr></thead><tbody><tr><td><strong><code>in_and</code></strong></td><td><span data-option="01t2Zj6y6nA6">Array</span></td><td>Matches if the <code>field</code> array contains all the items of the provided <code>in_and</code> array.</td></tr><tr><td><strong><code>in_or</code></strong></td><td><span data-option="01t2Zj6y6nA6">Array</span></td><td>Matches if the <code>field</code> array contains contains at least one of the items of the provided <code>in_or</code> array.</td></tr><tr><td><strong><code>not_in_and</code></strong></td><td><span data-option="01t2Zj6y6nA6">Array</span></td><td>Matches if the <code>field</code> array contains none of the items of the provided <code>not_in_and</code> array.</td></tr><tr><td><strong><code>not_in_or</code></strong></td><td><span data-option="01t2Zj6y6nA6">Array</span></td><td>Matches if the <code>field</code> array does not contain at least one of the items of the provided <code>in_or</code> array.</td></tr></tbody></table>

{% hint style="info" %}
Each of the operators above can be used **once** within the `value` object of the `array_match` matcher. If different operators are present, they are evaluated according to and `AND` logic (i.e. the `array_match` will match only if **all** the conditions in the `value` object are satisfied).&#x20;
{% endhint %}

#### Example

The following condition identifies the products in an order that are tagged as "man-accessories" or "women-accessories" *and* at the same time are not associated with both "sales" and "black-friday" tags (e.g. a line item associated with an SKU tagged as "men-accessories" and "sales" would match, while a line item associated with an SKU tagged as "women-accessories", "sales", and "black-friday" wouldn't match).

<pre class="language-json"><code class="lang-json">"conditions": [
  {
    "field": "order.line_items.sku.tags.name",
<strong>    "matcher": "array_match",
</strong>    "value": {
<strong>      "in_or": [ "men-accessories", "women-accessories" ],
</strong><strong>      "not_in_and": [ "sales", "black-friday" ]
</strong>    },
    "group": "accessories-not-already-on-sale",
  },
]
</code></pre>

### Aggregations

The matchers you can use when aggregating the [matches of a condition](/rules-engine/conditions/aggregations.md) or the [targets of an action](/rules-engine/actions/aggregation.md) are a subset of the [list above](#value-required). Namely (since they have to be checked against the results of an aggregation performed via [operators](/rules-engine/operators.md) that return numbers), the ones that can be applied to integer fields:

* `eq`
* `not_eq`
* `lt`
* `lteq`
* `gt`
* `gteq`
* `multiple`

For the same reason also the `value` attribute to be used within an aggregation must be of type integer.

## Value not required

You can find here below the complete list of the available matchers for which you don't have to provide a value in the related [condition](/rules-engine/conditions.md):

<table><thead><tr><th width="170">Matcher</th><th>Description</th></tr></thead><tbody><tr><td><strong><code>blank</code></strong></td><td>The <code>field</code> value is null or empty.</td></tr><tr><td><strong><code>present</code></strong></td><td>The <code>field</code> value is not null and not empty.</td></tr><tr><td><strong><code>null</code></strong></td><td>The <code>field</code> value is null.</td></tr><tr><td><strong><code>not_null</code></strong></td><td>The <code>field</code> value is not null.</td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.commercelayer.io/rules-engine/matchers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
