This article highlights and explains how to set up conditionals and combine features to build powerful, precise rules.
What are conditionals? And why should I use them?
A conditional statement (also called an If-Then Statement) is a statement with a hypothesis followed by a conclusion. Another way to define a conditional statement is to say, “If this happens, then that will happen.”
The antecedent is the first, or “if,” part of a conditional statement. The consequent is the second, or “then,” part of a conditional statement. The consequent is the result of the antecedent. Keep in mind that conditional statements might not always be written in the “if-then” form. Conditional statements may be nested such that either or both of the antecedent or the consequent may themselves be conditional or logical statements.
Info | title | Example Conditionals
---|
Examples of conditionals you can use in Hawksearch would be the following:
|
By using well-formed conditionals in Hawksearch to trigger actions, you can precisely enable actions like boost/bury, visibility rules, landing pages, item pinning, etc.
Table of Contents maxLevel 3
Navigation
Conditional statements are found in Hawksearch to program and select pools of items or content based on certain conditions. The image above highlights the basic features of a conditional trigger.
- ANY/ALL Selector Box
- Field Selection Dropdown Box
- Operator Selection Dropdown Box
- Value Input Field (Autocomplete Enabled)
- Add Condition Box
- Depth Adding Box
- Angled Bracket >> Adds a nested condition one layer below the selected condition.
- Minus: Clicking on this deletes the selected condition.
Instructions
From the basic rule box, you are able to set a conditional trigger using a logical conditional statement. When this statement is true then a defined rule or action will occur.
Clicking "Add Condition" allows users to set a new condition.
ANY vs. ALL
The ANY/ALL operation selects whether any condition makes the whole statement true, or if all conditions must be true for the whole statement to be true. This is easiest to explain using examples:
This statement is true if the an item is a Columbia Sportswear branded item.
This statement is true if the an item is a Columbia Sportswear branded item OR colored Red.
For this statement anything that satisfies either condition, Columbia brand or Red colored returns true for the whole statement.
Similarly, the following statement returns true for all Columbia, Salomon, and North Face products. Since any product in either of the three brands returns a true statement.
If you now switch the ANY to ALL, you realize that there is no product that satisfies the conditional. The only product that would make this statement true, must be branded as Columbia, Salomon, and The North Face at the same time.
To trigger an action for all Columbia branded items that were colored red, you would set up the following conditional:
Info | ||
---|---|---|
| ||
If a statement only has one condition, it doesn't matter if you use ANY or ALL since they are logically equivalent. |
Field Selection
You may select any field that is set toXXXXX.variable from the drop down box to be the field used to trigger an action.
Operators
Conditional statements in Hawksearch utilize several operators to logically evaluate statements. All operators are not applicable to each field, depending on if the operator is derived from data or from user inputs.
Info |
---|
Not all fields are capable of using all operators! Some fields are set as text strings, some as numbers, etc. The settings of a field determine what operators can be used. Also, if you're using a field condition that is explicitly in the data, your entry must be a perfect fit. For example, department name, color, or any other field. |
For numerical fields, the operators perform mathematical comparisons.
- Equals
- Does Not Equal
- Equals or Greater Than
- Equals or Less Than
- Greater Than
- Less Than
Anchor | ||||
---|---|---|---|---|
|
This is the operator to use when you want to target part of a field or keyword. For example, if you want to show a banner to anyone who searches for a Nike branded item in the search bar, even if they specify a type of clothing or attire after it, you could use the following statement. Searches for "Nike", "Nike shoes", "Nike pants", "Nike bag", "Nike ball", and "Nike football gear" would all return true for the following conditional.
Anchor | ||||
---|---|---|---|---|
|
This is the operator to use when you want to target part of a field or keyword, while excluding a subset of the results. For example, if you want to show a banner for a hammock sale to anyone who searches for camping in the search bar, while excluding anyone who searches for tents you may set up the following trigger.
Anchor | ||||
---|---|---|---|---|
|
Use Contains In when you want to search for any one of several terms to make the conditional true. Think of this as an OR statement. The following example will return true if someone inputs any of the following words into the search bar as a keyword or part of a keyword: camping, hiking, adventure, and sleeping bags.
Does Not Contain In
Instructions
...
Anchor | ||||
---|---|---|---|---|
|
This operator, Does Not Contain In, negates contains in and is useful to use when you want to exclude part of a data set. Below the example would target search terms for a vacation, that are not summer or water themed.
Anchor | ||||
---|---|---|---|---|
|
The Is operator is for an exact match. This is useful when you want to target fields that are clear and precise. For example to target an action for users who are searching or navigating in the Men's and Women's Sportwear Departments, the following trigger would be set up. (Note that ANY must be selected to make sure that every item in either Men's Sportwear or Women's Sportwear would be displayed. If you used ALL, the search would break since it's unlikely that there are items that satisfy both conditions and are in both departments simultaneously.)
Anchor | ||||
---|---|---|---|---|
|
The Is Not operator is for an exact match in one term while being able to exclude a subset of the larger condition. This is useful when you want to target fields that are clear and precise. For example to target an action for users who are searching or navigating in the anywhere in the Men's Sportwear Department except for the "North Water Paddle Sport" brand, the following trigger would be set up. (Note that ALL must be selected to make sure that every item that is in Men's Sportwear AND is not from the particular brand would be displayed. If you used ANY, the search would be too broad and would show undesired results since it would return items that satisfy either condition and items that satisfy both.)
Anchor | ||||
---|---|---|---|---|
|
The Is in operator is for any one a series of possible exact matches. Think of Is In as IS with an OR in between each term. For example,
This is logically equivalent to this case with the ANY condition setting enabled:
Here's a case where using is in makes a logical condition much easier to understand and implement.
If you wanted to target all boots that were on sale:
Without using Is In, the implementation requires nested statements where another layer of logic is implemented.
Similarly, if you wanted to execute the same statement, while evaluating for departments before checking if an item was on sale, this would require a significantly more complex execution. (This may be the optimal way to do it based on your specific data's structures and characteristics.)
Combining Conditional Statements:
As you have seen from the examples above, complex conditionals can be designed creatively to give you many options to capture a group of items. You can set up series of conditionals using any/all to capture a large group of conditions or an item that satisfies many different conditions. There are many examples of this shown above in explaining the operators. You can nest statements to pick a subset of one condition and not another. For example, the following statement needs to be nested to target both men's boots that cost more than $150 and women's boots over $200 at the same time.
Related articles
Filter by label (Content by label) | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
...
Page Properties | ||
---|---|---|
| ||
|