Author:
Esma Tuzovic
Changed on:
3 June 2024
The Mystique manifest configures icons, cards, and templates. Templates can be structured in various ways; for further details, please consult the UX Configuration Common Concepts article. This article, however, will specifically concentrate on the any Match template.
This template functions as a filter for a stream (such as a list of items), capable of matching none, some, or all records where a specific condition is met by a field path. This feature is particularly valuable for filtering purposes.
`STRING_PATH_TO_VARIABLE`
`VALUE`
`OPTIONAL_FUNCTION .`
All `anyMatch`
1{{anyMatch 'STRING_PATH_TO_VARIABLE' 'VALUE' 'OPTIONAL_FUNCTION'}}
Language: plain_text
Name: Syntax
Description:
[Warning: empty required content area]`STRING_PATH_TO_VARIABLE`
A dot-separated string that outlines the path to a variable within your data structure, navigating through both objects and arrays at intermediary levels. The path
`"node.entity.field.subfield1"`
`subfield1`
`{node: {entity: {field: {subfield1: ...}}}}`
`node`
`entity`
`field`
`subfield1`
`includes`
1{
2 "node": [
3 {
4 "entity": {
5 "field": [
6 {
7 "subfield1": ["alpha", "beta"],
8 "subfield2": "delta"
9 },
10 {
11 "subfield1": ["gamma"],
12 "subfield2": "theta"
13 }
14 ]
15 }
16 }
17 ]
18}
Language: json
Name: Example Data Structure with Arrays
Description:
[Warning: empty required content area]`anyMatch`
`subfield2`
`"delta"`
`{{anyMatch "node.entity.field.subfield2" "delta" "eq"}}`
`'true'`
`subfield2`
`"delta"`
`subfield1`
`"beta"`
`{{anyMatch "node.entity.field.subfield1" "beta" "includes"}}`
`'true'`
`subfield1`
`field`
`"beta"`
`anyMatch`
`node`
`node`
`entity`
`field`
`field`
`subfield1`
`subfield1`
`eq`
`subfield1`
`includes`
`VALUE`
The
`VALUE`
`anyMatch`
`STRING_PATH_TO_VARIABLE`
`VALUE`
`anyMatch`
`eq`
`ne`
`includes`
`like`
`{{anyMatch "node.entity.field.subfield1" "expectedString" "eq"}}`
`subfield1`
`'expectedString'`
`VALUE`
`anyMatch`
`lt`
`gt`
`lte`
`gte`
`{{anyMatch "node.entity.field.quantity" 100 "lte"}}`
`quantity`
`100`
`VALUE`
`true`
`false`
`anyMatch`
`{{anyMatch "node.entity.field.isActive" true "eq"}}`
`isActive`
`true`
`VALUE`
`otherValue`
`{{anyMatch "node.entity.field.subfield1" otherValue "eq"}}`
`subfield1`
`otherValue`
`anyMatch`
`OPTIONAL_FUNCTION`
A string representing the comparison or operation you want to perform. Supported functions include:
`"eq"`
`"ne"`
`"lt"`
`"lte"`
`"gt"`
`"gte"`
`"includes"`
`"like"`
`"likeIncludes"`
`true`
`false`
Operator | Expectation | Behavior | Use Case Example with Array at Any Level | Use Case Example without Array |
"eq" | Any data type | Checks exact equality. Iterates through arrays at any level in the path and stops at the first match found in the specified field. | { node: { entity: [{ field: { subfield1: [{ itemId: ‘1234' }] } }] } } with {{anyMatch "node.entity.field.subfield1.itemId" "1234" "eq"}} → 'true' if any “itemId” under subfield1 array is equal to '1234'. | { node: { entity: { field: { subfield1: { itemId: '1234' } } } } } with {{anyMatch "node.entity.field.subfield1.itemId" "1234" "eq"}} → 'true' |
"ne" | Any data type | Checks inequality. Iterates through arrays at any level in the path and stops at the first non-matching field. | { node: { entity: [{ field: { subfield1: [{ itemId: '1234' }] } }] } } with {{anyMatch "node.entity.field.subfield1.itemId" "1234" "ne"}} → 'true' if any “itemId” under subfield1 array is not '1234'. | { node: { entity: { field: { subfield1: { itemId: '1234' } } } } } with {{anyMatch "node.entity.field.subfield1.itemId" "1234" "ne"}} → 'true' |
"lt" | Numeric data types | Checks if less than provided value. Iterates through arrays at any level in the path and stops at the first match found. | { node: { entity: [{ field: { subfield1: [{ itemQty: 3 }] } }] } } with {{anyMatch "node.entity.field.subfield1.itemQty" 5 "lt"}} → 'true' if any itemQty under subfield1 array is less than 5. | { node: { entity: { field: { subfield1: { itemQty : 3 } } } } } with {{anyMatch "node.entity.field.subfield1.itemQty" 5 "lt"}} → 'true' |
"lte" | Numeric data types | Checks if less than or equal to provided value. Iterates through arrays at any level in the path and stops at the first match found. | { node: { entity: [{ field: { subfield1: [{ itemQty: 5 }] } }] } } with {{anyMatch "node.entity.field.subfield1.itemQty" 5 "lte"}} → 'true' if any itemQty under subfield1 array is less than or equal to 5. | { node: { entity: { field: { subfield1: { itemQty: 5 } } } } } with {{anyMatch "node.entity.field.subfield1.itemQty" 5 "lte"}} → 'true' |
"gt" | Numeric data types | Checks if greater than provided value. Iterates through arrays at any level in the path and stops at the first match found. | { node: { entity: [{ field: { subfield1: [{ itemQty: 6 }] } }] } } with {{anyMatch "node.entity.field.subfield1.itemQty" 5 "gt"}} → 'true' if any itemQty under subfield1 array is greater than 5. | { node: { entity: { field: { subfield1: { itemQty: 6 } } } } } with {{anyMatch "node.entity.field.subfield1.itemQty" 5 "gt"}} → 'true' |
"gte" | Numeric data types | Checks if greater than or equal to provided value. Iterates through arrays at any level in the path and stops at the first match found. | { node: { entity: [{ field: { subfield1: [{ itemQty: 5 }] } }] } } with {{anyMatch "node.entity.field.subfield1.itemQty" 5 "gte"}} → 'true' if any itemQty under subfield1 array is greater than or equal to 5. | { node: { entity: { field: { subfield1: { itemQty: 5 } } } } } with {{anyMatch "node.entity.field.subfield1.itemQty" 5 "gte"}} → 'true' |
"includes" | Iterable collection (array/string) | Checks if collection includes provided value. Iterates through arrays at any level in the path and stops at the first match found. | { node: { entity: [{ field: { subfield1: [{ sellableQty: [1, 2, 3] }] } }] } } with {{anyMatch "node.entity.field.subfield1.sellableQty" 2 "includes"}} → 'true' if any sellableQty array under subfield1 array includes 2. | { node: { entity: { field: { subfield1: { sellableQty: '123' } } } } } with {{anyMatch "node.entity.field.subfield1.sellableQty" "2" "includes"}} → 'true' |
"like" | String data types | More flexible match which is case insensitive . Iterates through arrays at any level in the path and stops at the first match found. | { node: { entity: [{ field: { subfield1: [{ key: 'hello world' }] } }] } } with {{anyMatch "node.entity.field.subfield1.key" "world" "like"}} → 'true' if any key under subfield1 array is like world. | { node: { entity: { field: { subfield1: { key: 'hello' } } } } } with {{anyMatch "node.entity.field.subfield1.key" "llo" "like"}} → 'true' |
"likeIncludes" | Iterable collection (array/string) | Combination of the above two functions that will perform a case insensitive partial string match on arrays. | { node: { entity: [{ field: { subfield1: [{ customers: ['John Smith', 'Albert Fumbledoor', 'Bilbo Haggins'] }] } }] } } with {{anyMatch "node.entity.field.subfield1.customers" "door" "likeIncludes"}} → 'true' if any customers array under subfield1 array includes 'door'. | { node: { entity: { field: { subfield1: { customer: 'Samwise Crabtree' } } } } } with {{anyMatch "node.entity.field.subfield1.sellableQty" "tree" "includes"}} → 'true' |
Copyright © 2024 Fluent Retail Pty Ltd (trading as Fluent Commerce). All rights reserved. No materials on this docs.fluentcommerce.com site may be used in any way and/or for any purpose without prior written authorisation from Fluent Commerce. Current customers and partners shall use these materials strictly in accordance with the terms and conditions of their written agreements with Fluent Commerce or its affiliates.