Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Import Macro Repair

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.


Example Conditionals
Info
title

Examples of conditionals you can use in Hawksearch would be the following:  

  • If an item is on sale, then boost it relative to the top of other relevant search results. 
  • If an item is discontinued or out of stock, then hide it. 
  • If an item is cheaper than other items in the search results, then bury it to the bottom of the results. 
  • If an item is a very popular item in the department, then pin it to the top of the search results for the department name.  

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
maxLevel3

Navigation

Image Added

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. 

  1. ANY/ALL Selector Box
  2. Field Selection Dropdown Box
  3. Operator Selection Dropdown Box
  4. Value Input Field (Autocomplete Enabled)
  5. Add Condition Box
  6. Depth Adding Box
    1. Angled Bracket >> Adds a nested condition one layer below the selected condition. 
    2. 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. 

Image Modified

Clicking "Add Condition" allows users to set a new condition. 

ANY vs. ALL

Image RemovedImage Added

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. 

Image RemovedImage Added

This statement is true if the an item is a Columbia Sportswear branded item OR colored Red. 

Image RemovedImage Added

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. 

Image RemovedImage Added

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. 

Image RemovedImage Added

To trigger an action for all Columbia branded items that were colored red, you would set up the following conditional: 

Image RemovedImage Added

Info
titleSingle condition

If a statement only has one condition, it doesn't matter if you use ANY or ALL since they are logically equivalent.  

Field Selection

Image RemovedImage Added

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.     

Image RemovedImage Added

  1. Contains
  2. Does Not Contain
  3. Contains In
  4. Does Not Contain In In 
  5. Is 
  6. Is Not
  7. Is In 
  8. Is Not In


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. 

Image Added

  1. Equals 
  2. Does Not Equal
  3. Equals or Greater Than
  4. Equals or Less Than
  5. Greater Than
  6. Less Than

Anchor
Contains
Contains

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.    

Image RemovedImage Added

Anchor
Does Not Contain
Does Not Contain

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. 

Image RemovedImage Added

Anchor
Contains In
Contains In

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.  

Image Removed

Does Not Contain In

Image Removed

Image Removed

Image Removed

Image Removed

Image Removed

Image Removed

Image Removed

Image Removed

Instructions

...

Image Added

Anchor
Does Not Contain In
Does Not Contain In

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. 

Image Added

Anchor
Is
Is

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.)

Image Added

Anchor
Is Not
Is Not

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.)

Image Added

Anchor
Is In
Is In

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,  

Image Added

This is logically equivalent to this case with the ANY condition setting enabled: 

Image Added

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: 

Image Added

Without using Is In, the implementation requires nested statements where another layer of logic is implemented. 

Image Added

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.)

Image Added

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.  

Image Added 

Filter by label (Content by label)
showLabelsfalse
max5
spacescom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@21fba2
showSpacefalse
sortmodified
reversetrue
typepage
cqllabel in ( "conditional" , "in" , "contains" , "trigger" , "is" ) and type = "page" and space = "HSKB"
labelsconditional trigger is in contains

...

Page Properties
hiddentrue


Related issues