Logic & Rules - Cheat Sheet
Introduction
The preezie logic/rules use “Lucene query syntax”.
There are different types of logic that can be set up under the “Rule Condition”:
The option for general rules and logic in preezie is the “Partial String Match” option in the Rule Conditions section in the answers.
Note: The Rule Condition above does not require you to configure when importing a Journey Q&A. ONLY if you are looking to adjust logic to an alternate condition will you need to adjust this manually.
Partial String Match |
Rules can be mixed and matched to create some CRAZY Advanced Logic that will work wonders for a selected answer.
In the examples below we will be using the values Red, Green and Blue to see how syntax can be applied in logic/rules.
You will need to ensure that Special Characters are “escaped” for logic to function correctly.
Special characters:
Add a \ before a special character will “escape” the proceeding character from the search.
Special characters are + - && || ! ( ) { } [ ] ^ " ~ * ? : / \
Double Pipe ( || ) = OR
Basic Rules:
In the rule this must be separated by a double pipe || and have "double quotes" to group it. | "dark red"||"dark green"||"really dark blue"||Red |
If a two or more words are joined by a hyphen ( - ) you need to put quotes around it even though there is no space. | "dark-red"||"dark-green"||"dark-blue" |
You can add a single word with no need to putting quotes around the single words. | "dark red"||red||"dark green" |
Exclude Rules:
Excluding a word like “red” or phrase with a ! | !red||!"dark red"||green||blue||"dark blue" |
To exclude just a single world you will need to put the exclusion in brackets. | (!red) |
Wild Card Search:
Search for the letters anywhere in a phrase with (*Stars*) so greenery or evergreen could be located with this rule. USE WITH CAUTION! | (*green*) |
Wild Card Search can also be used in other logic where appropriate. This rule can be used with other rules but needs to be wrapped in brackets | (*green*)||(*blue*)||red |
Search more than one field:
NOTE: Fields in these rules are case-sensitive.
To search in one or more fields for key words you are required to add an OR between the fields with a space. CAPITAL LETTERS please. | body_html:() OR tags:() |
Add any rule between brackets. | body_html:(red) OR tags:(red||"dark red") |
Advanced searching with an AND. | product_type:(shirt||jumper) AND tags:(best_seller) |
Excluding word(s) from multiple fields put the ! infront of the field to exclude all words from that field. | !body_html:(red) OR !tags:(red||"dark Green") |
Exclude products that include a seperate tag with an AND between the fields. | product_type:(shirt||jumper) AND !tags:(best_seller) |
Fuzzy Search:
Fuzzy Search allows you to search for variations on words. green~ will also find greed, gren, greens, gleen among other things. | green~ |
Proximity Search:
Proximity matching is where you can find multiple words within a specific distance from each other. e.g. Search for green and blue where they are within 4 words from each other. | "green blue"~4 |
Advanced Logic examples
In this section, we will look at some use cases for advanced logic that can be used to assist you in the development of your own journey.
Example 1:
If you have a single question that is asking a variety of things at once this may be helpful for you.
If the question asks “What type of fabric would you like for your Hoodie?”, and you have not already asked for the type of product, “hoodie” for example, we can combine all of those options in a single answer.
The answer options are 1. Wool. 2. Not Wool.
Output:
Answer 1. “Woolen”
Answer 2. “Not woolen”
Data:
The product type for the hoodies is “Jumper”, all the other data points are located in the tags field.
product_type: | tags: |
---|---|
jumper | hoodie, wool |
Logic:
Answer 1. Woolen | (product_type:(jumper) AND tags:(hoodie)) AND tags:(wool) |
Answer 2. Not woolen | (product_type:(jumper) AND tags:(hoodie)) AND !tags:(wool) |
Example 2:
If there is an issue with the cleanliness of the data in the feed this may be helpful to you. We are searching for product features for TVs in the example below.
If the question asks “What features are you looking for?”, but the data has a list of features listed in one field such as the description. OR there is a string of messy data in the tags field.
The answer options are 1. 4K UHD. 2. Smart TV. 3. OLED Screen. 4. Gaming Ready
Output:
Answer 1. “4K UHD”
Answer 2. “Smart TV”
Answer 3. “OLED Screen”
Answer 4. “Gaming Ready”
Data:
The data can be used from one or two fields depending on where the data is located. This can be different for different products, make sure to check several products in the category to ensure that the data you are looking for is in the correct field for all of the products. e.g. If a TV in this example has data only in tags, you should only search in tags if all other TVs have the same structure. If TVs have data in both you can search in both to ensure you do not miss an outlier that may only have the data located in the description.
The example data below has all the data we need for all the answers in both the description and the tags.
Bold and colored for your convenience, these are the fields identified to fit with the answers above.
Some of this data may not be obvious, “gaming” is clearly defined in the description in Green, however, the tags are where the Refresh Rate 200Hz and the HDMI 2.1 make this a good gaming TV. Ensure you know what makes a product suitable for an answer. These can sometimes require some research.
desctiption: | tags: |
---|---|
<STRONG>Overview</STRONG> <P></P><P>Into the wonderful: experience the next evolution of LG OLED TV. Self-lit pixels allow spectacular picture quality, a host of design possibilities and cutting-edge Smart TV technologies designed to deliver everything you love about TV, elevated in every way. </P><P><STRONG>Key Features</STRONG></P><P><STRONG>Our best 4K OLED ever</STRONG><BR>See bright, sharp images with intense clarity, from an upgraded display. LG OLED evo uses an optimised next-generation OLED panel that refines the wavelengths of light and increases brightness. Evolve your viewing experience with an evolved display. </P><BR><FONT size=1>*FILMMAKER MODE™ is a trademark of UHD Alliance, Inc.</FONT></P><P><STRONG>It's game over for the competition</STRONG><BR>Get ahead of the game with swift response, cutting-edge gaming features and an ultra-smooth display. Create the ultimate gaming setup, with LG OLED TV. </P> | Screen type: OLED TVs, LG TV model: OLED G1 4K, Screen Resolution: 4K_Ultra HD, Screen Size (Inches): 77, Refresh Rate (Hz): 200Hz, Variable Refresh Rate (VRR): HDMI VRR, HDR (High Dynamic Range): True, Backlighting type: Self-lighting, Local dimming: True, 4K Ultra HD disc compatible: False, 4K streaming compatible: True, Noise reduction: True, Movie/cinema Mode (24 FPS): True, NTSC to PAL conversion: False, Picture In Picture: False, Streaming apps: 7Plus, Apple TV, 9Now, ABC iView, Amazon Prime, britbox, Disney+, Foxtel Now, Netflix, HDMI-CEC: False, HDMI inputs: 4, HDMI 2.1 inputs: 4, USB Ports: 3, Brand: LG, Category: TVs OLED 75" and above, Primary Category: TVs, Availability: Available Now |
Logic:
Answer 1. 4K UHD | description:(UHD||4K||”Ultra HD”) OR tags:(UHD||4K||”Ultra HD”) |
In Answer 1 logic above the logic is a simple search in two fields, ensure that logic with multiple words are “bracketed”, the others are not required to have quotes.
Answer 2. Smart TV | description:(“smart tv”) OR tags:(7Plus||”Apple TV”||9Now||”ABC iView”||”Amazon “Prime||britbox||Disney\+||“Foxtel Now”||Netflix) |
In Answer 2 logic above there is a Special Character in the Disney+ part of the logic the ( + ) is a special character and needs to be escaped with a backslash ( \ ).
Answer 3. OLED Screen | (description:(OLED) OR tags:(OLED)) AND (description:(TV) OR tags:(TV)) |
In Answer 3 logic above we are searching for OLED in two fields but AND making sure that we are looking for only TV options, as there are other OLED products such as Phones & Laptops. If we changed the AND in the logic above to an OR we would be searching for OLED or TVs, opening up the logic to other devices.
Answer 4. Gaming Ready | description:(gaming) OR tags:(gaming||”HDMI 2.1”||250HZ||200HZ||150HZ||100HZ) |
In Answer 3 logic above we are searching for all the required key words but are also including the different Hz frame rate options as there may be other TVs that work well for gaming.
Bonus Value Search Logic
In this section, we will look at how you can use search between a range, greater than or less than a value.
Import Template value search:
NOTE: The preezie Import template converts all values to currency, it will include $ Dollars & c Cents.
So $50 will become 5000 once imported, it is always without the decimal (.)
If you would like to import without the extra (00)'s speak to your CSM.
Searching for a value, Greater than a number | >50 |
Searching for a value, Less than a number | <50 |
Search for a value Between a Range | 50 - 100 |
Range Logic - use as a Match Rule:
DO NOT USE THIS LOGIC UNLESS UNDER DIRECT SUPERVISION OF A preezie CS Manager.
preezie has integrated tools to search for number ranges in the system (see previous example).
Why use this logic with the warning label above?
This logic will allow for rules to conditionally use value searches & string searches at the same time.
Searching for Number values between a range | Product_Size:[50 TO 100] |
Searching for Price value between a range | Product_Price:[5000 TO 10000] |
Advanced searching with an AND. | Product_Price:[5000 TO 10000] AND Category:("headphones") |