Query rules

Query rules is an extension of features available in the AI Search Engine. Due to the logic behind query rules which is based on if something, then do something structure, you can interfere with the search results. You can promote specific products, replace the query or word in the query or remove a word from it.


Requirements

  • Delivered product feed
  • Integration of events via AI tracking or API
  • Transactional data (minimum 3-month history) periodic transaction updates (one week history)
  • Online data stream including different channels if possible (recommended)

Creating query rules

Go to Search engine -> Query rules

description

Define conditions

You need to define the condition that must be met so the effect of the query rule can be achieved. Condition pattern, which is the most important in the context of the whole query, is composed of a string of elements which are treated as a phrase. Remember that the elements must be placed in a specific order.

The allowed types of elements:

  • Literal - The basic type of element which is simply a word (cannot be a phrase), in a singular form, with no typos allowed.
  • Facet value placeholder - Facet is an aspect of data by means of which data can be filtered. In practice a facet is an attribute of a product and the value of the facet can be a phrase. Matching is case insensitive, however, the word order is of great importance as the condition pattern is a phrase.

The condition is checked from the beginning to the end of the phrase whether it concides with the one of the chosen settings:

description

  • is - A phrase in the condition needs to match exactly the whole phrase used by the customer.
  • contains - A phrase in the condition needs to match only a part of the phrase used by the customer.
  • starts with - A phrase in the condition needs to match the beginning of the phrase used by the customer.
  • ends with - A phrase in the condition needs to match the end of the phrase used by the customer, however, there may be extra words at the beginning.

Define consequences

The search engine adapts its behavior according to the consequences associated with a condition. These are the possible actions that can happen in response to the fulfilled conditions:

description

  • Replace query - When a customer uses a specified phrase in the search query, you can replace it with another one.
  • Replace word - When a customer uses a specific word in a query, you can replace it with other.
  • Remove word - When a customer uses a specific word in a search query, you can remove it from the query.
  • Promote item - When a customer uses a specific query, you can promote a product in the search results.
  • Hide item - When a customer uses a specific query, you can hide some products from the search results.
  • Filter query results - Depending on the phrase used in a search query, you can filter the results according to the category, brand, size, color and gender.

description

At the end of the process define when you want to activate your query rules. It can be activated at once or you can schedule the date of activation.


Conflicting rules

When you create query rules, they usually will concern various and distinct cases, however, bear in mind that the more rules you create, the greater possibility of the conflict is.

Conflict emerges in a situation when the two query rules concern the same phrase and their consequences are mutually exclusive. The system resolves such conflicts by means of precedence logic which criteria are explained below.

Note: Multiple rules can still match a given query, provided they match a distinct set of words.

Precedence logic

In order do indicate the precedence of the query rules, the system uses an algorithm. The precedence logic, ranked by importance, is as follows:

  1. Position: The earliest match wins (i.e. closest to the beginning of the query string).
  2. Match length: The longest match wins (in terms of the number of words from the query string).
  3. Settings: is > starts with > ends with > contains.
  4. Context: A contextual rule has higher priority than a general rule.
  5. Literals over placeholders: If a word could match both a literal or a facet value, the literal takes precedence.
  6. Temporary over permanent: If both a temporary rule and a permanent rule match, the temporary rule takes precedence.
  7. Rule ID: If there are still conflicts after all other criteria have been applied, we just take the smallest objectID in lexicographical order. This final tie-breaker rule is guaranteed to break every tie and it will most likely only be used when there are duplicate rules.

Essentially, rules are applied from left to right (or more precisely, from the beginning of the query string to its end).

Conflicting consequences

Precedence logic is used with regard to the conflicts connected with conditions. It does not apply in the situation when there is no direct conflict.

However there might be a case, when the query consists of various phrases, but their consequences overlap, like in the example below when a query contains bedroom furniture that co-exists with other two query rules:

  1. If a query contains phrase bedroom, then promote Bed frame 123.
  2. If a query contains phrase furniture, then promote Wardrobe 123

In this case, the two different rules fight for the first position in the results and there is no conflict, as the conditions are completely different. The third query combines two phrases from queries above, and in this case there is no clear-cut logic that indicates the winning product that will be promoted. Sometimes the result is based on the dates of creating the rules, however, the best practice is to avoid this kind of situation.

Edge cases

  1. If a rule removes a word from the query string, all subsequent rules that would have been triggered by this word (either via a literal or a facet placeholder) are disabled.
  2. If a rule replaces the query string entirely, all subsequent rules are disabled.
😕

We are sorry to hear that

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

😉

Awesome!

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.