Filtering allows you to define the conditions an item must meet to be displayed in the recommendation frame. Such recommendation frame can be displayed, for example, in the contents of the email or on your website.
Filtering concerns all attributes of items that you declared to be filterable while configuring AI engine. Filterable attributes can be of the following types: string, integer, float, boolean, nested objects, arrays.
The attribute names are case sensitive, however the filter values are not. So, filter
brand == "SAMSUNG" is equivalent to
brand == "samsung", but different than
Brand == "samsung".
You have a possibility to create a filter by using two filter wizards:
- Visual Builder - You can construct the filter conditions similarly to creating a segmentation in the Analytics module.
- IQL query - Advanced users may construct a formula of the filter, which is a similar to creating expressions. Out of the building elements (functions, variables, strings, numerical values, arrays) and mathematical operators, they can create filter conditions.
In the visulal builder, you need to define the filters by:
- selecting one or more attributes
- describing the condition for the attribute using operators and their values
- defining the dependency between the filters by preparing a formula
- A product feed is already chosen (in this example, the product feed name is
- From the dropdown list, select an attribute of an item (in this example,
brandis the selected attribute).
Result: The Operator button appears.
Describing conditions by operators
The next step is defining the conditions concerning the selected attribute by using operators. The list of operators contains:
- Is defined - If the selected attribute has any other value than
null. For example, if a filter is set to “
brandis defined”, the recommendation frame contains only those items which have a specified brand (in the product feed).
- Equal - If the selected attribute has an exact value. For example, if a filter is set to “
acme”, then the recommendation frame contains items of Acme brand.
- Does not equal - It excludes a particular value of an attribute. For example, if a filter is set to “
branddoes not equal
acme”, then the recommendation frame contains all items except for the items of Acme brand.
- In - It checks whether the attribute is present in a selected array(s). For example, if a filter is set to “
red, blue/array/”, then the recommendation frame contains all items that are in the red and blue color.
- Less than - For example, if a filter is set to “
50”, then the recommendation frame contains items that are cheaper than 50 dollars (or other currency you use).
- Less than or equals - For example, if a filter is set to “
attribute.sizeless than or equals
43”, then the recommendation frame contains items of size 43 or less.
- More than - For example, if a filter is set to “
10”, then the recommendation frame displays those items whose quantity in your stock is greater than 10.
- More than or equals - For example, if a filter is set to “
discountAmountmore than or equals
20”, then the recommendation frame displays items which are discounted by $20 or more.
Defining the values of operators
The examples presented in the Describing conditions by operators section, already contain the value of the operator. There are five types of the values:
- Selected value - Out of the list of attributes sourced from the feed, you select one, like in the example: “
- Context selected value - In the case of similar items, visually similar items, cross-sell recommendations, you can display items of the same attribute as the item currently viewed. For example:
- An array - Allows to include items in a specific group, like in the example: “
red, blue/array/” (available only for the In operator)
- Number - Allows you to define the numerical value.
- Formula - it is created in the IQL Query builder. It allows you to define the advanced conditions, which can be done with the available operators and its value types. For example, if you want to display in the recommendation frame items which are discounted more than the currently viewed product.Click here to see the tutorial for the Formula example
You can change the type of the value operator by clicking this icon:
Defining filter conditions
You can define how filters coexist by defining the dependency between them by using logical operators. Below you can find exemplary configuration of filters.
The IQL Query wizard allows for a greater flexibility of creating the formula of the filter due to the wide range of elements and the possibility combine them using mathematical operators.
Elements of the formula
The filter formula can be built of the following elements:
Strings (a sequence of characters)
Variables (three types: a variable [any parameter], context variable [a parameter of an item a customer is currently viewing], and boolean)Tip where to find it on the interface
Arrays (a group of elements)
Take All (include all items)
Take None (include no items)
FunctionsClick to see the list of functions
Function Description Syntax & Example of use ADD Adds a constant to value of a selected variable 1. Syntax 2. Example of use In this example, a recommendation frame shows items which are more expensive than the currently viewed item by $20. AVG Returns the average value of a selected attribute (for example, a shoe size) 1. Syntax 2. Example of use In this example, a recommendation frame shows items that have the average size in relation to size of the currently viewed item. CATEGORY Allows to define the categories to be included or excluded while filtering items 1. Syntax 2. Example of use In this example, a recommendation frame shows items of exactly the same category as the currently viewed product. In this example, all items that belong exactly to
Electronics > Phones and Smartphones > Smartphones, or in one of the subcategories of
Electronics > Phones and Smartphones > Smartphonesare shown in the recommendation frame. The filter also includes items that have the category defined in the
additionalCategoriesparameter.Note: The number defines how many subcategories from the right should be dropped. If in the second example
0was replaced with
1, these would be the categories included in the filter:
Electronics > Phones and Smartphones.
IF Allows logical comparisons between values and defining actions to be performed when the condition is met or not. 1. Syntax 2. Example of use Explanation is available in the Examples of use section (example 3). MULTIPLY Multiplies the value of a variable by a specified constant 1. Syntax 2. Example of use In this example, a recommendation frame shows items whose final price is higher than the price of the current item multiplied by
MIN This function returns the lowest value in a set of values 1. Syntax 2. Example of use In this example, a recommendation frame shows items whose size is larger than the smallest size of the currently viewed items. MAX This function returns the highest value in a set of values. 1. Syntax 2. Example of use In this example, a recommendation frame shows items whose size is larger than the largest size of the currently viewed items. NOT Negates a filter 1. Syntax 2. Example of use In this example, a recommendation frame shows items of all colors except for pink.
The elements of the filter formula can be combined with the following mathematical operators:
Apart from the symbols of mathematical operations such as addition, subtraction, multiplication, or division, you can use logical operators such as
ORhave the same function in the formula as
ORin the Visual Builder (which is defining conditional dependencies between filters).
The same concerns the
INoperator, in both wizards it allows you to include an array in the filter conditions.
Creating a formula in the wizard
Using the elements listed above and mathematical operators, you can create a filter formula that defines the conditions an item must meet in order to be displayed in the recommendation frame.
In the tutorial below, the condition of the filters states that the recommendation displays only items that are of the same brand as the item currently displayed by a customer and the number of available items in the stock is higher than 12. If an item doesn’t meet two conditions simultaneously, it won’t be displayed in the recommendation frame.
Comparison between filters
The table below shows the same business application of the filter in the two filter wizards. The further parts of the article include the explanation of the similar examples as those presented in the table.
|Visual Builder||IQL Query|
|Visual builder||IQL Query|
|- Creating separate filters and then
defining conditional dependencies between them
- A separate option for matching/not matching filter conditions
- A separate option for defining formula of conditions
- Lack of the elements: functions, take none and take all options (available in the IQL Query wizard)
- The range of options available to build filter
conditions and the form of building the conditions may restrict the scope of business applications
|- One formula involves all conditions and dependencies between them
- Additional elements that visual builder lacks (functions, take all, take none)
- Possibility to create filter conditions for advanced business applications