Introduction
The preezie logic/rules use “Lucene query syntax”.
For The two types of logic that can be set up under the “Rule Condition” are:
Text/String Equals To | Partial String Match |
Both of these options can be found in the answers configuration in the preezie system.
In the examples below we will be using the values Red, Green and Blue to see how syntax can be applied in logic/rules.
Special characters:
Add a \ before a special character will “escape” the proceeding character from the search.
Special characters are + - && || ! ( ) { } [ ] ^ " ~ * ? : \
Text/String Equals To |
“Text/String Equals To”, is the most simple search. Only able to search for uninterrupted strings of characters, a single word like “red”, NOT “dark red” as that is interrupted by a space.
If you have a phrase with characters separated by a space or a special character the “Rule Condition” is a “Partial String Match”.
Single Pipe ( | ) = OR
Single words must be separated by a single pipe | | red|green|blue |
Words split by underscores ( _ ) are classified as uninterrupted. These can also be separated by a single pipe | | dark_red|light_green|pale_blue|green |
A rule that has a hyphen ( - ) joining text is considered a special character in Lucene query.
If you would like to do something like dark-red as logic it will be considered a “Partial String Match”, see below for more information.
Partial String Match |
Rules can be mixed and matched to create some CRAZY Advanced Logic that will work wonders for a selected answer.
You will need to ensure that Special Characters are “escaped” for logic to function correctly.
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:(beset_seller) |
Excluding word(s) from multaple 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:(beset_seller) |
Fuzzy Search:
Fuzzy Search allows you to search for variations on words. red~ will also find redish, reds, rez among other things. USE WITH CAUTION! | red~ |
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 | (prodcut_type:(jumper) AND tags:(hoodie)) AND tags:(wool) |
Answer 2. Not woolen | (prodcut_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 options in the data before committing to searching in a specific field.
desctiption: | tags: |
---|---|
Logic:
Answer 1. 4K UHD | (prodcut_type:(jumper) AND tags:(hoodie)) AND tags:(wool) |
Add Comment