Interface InputSearchRuleMatch

Rule match specifies when the rule will be applied. Parameters groups are sent based on match type that you are using. Only send parameters which belong to the filter type you are using.

Everything match - matches every time. Used for global rules that should be applied on every request Example:

{
"everything": true
}

Param match - extracts value from specified search request param and compares it to expected value. If param value matches expected value, the rule is applied. Values are preprocessed before comparing them (lowercased, phrases split into tokens, etc.). Both input values and expected values are preprocessed using the same logic before comparison. At least one item from expected value array must match for the rule to match as a whole.

Example - apply rule when user searches for battery

// user's search request
{
"query": "battery",
...
}

// rule
{
"param": "query",
"value": ["battery"]
}

In this case, no function was used, so values were processed minimally and exact match was applied. You can change this behavior using one of available functions

Param Stem match - used when you want to use exact match but you want to match different variations of the word. In the previous example, rule would match with search query battery, but will not with batteries. To solve his, provide stem match function:

{
"param": "query",
"value": ["battery"],
"function": "stemmed"
}

Param Contains match - used if you care about terms appearing in search query but don't care about order. Values are processed in the same way as if no function was provided. Matching is done using contains match. If you have a rule:

{
"param": "query",
"value": ["battery"],
"function": "contains"
}

It will match with search query battery, A4 battery, Li-ion battery, etc.

Param Stemmed Contains match - values are stemmed and applies a contains match. With rule:

{
"param": "query",
"value": ["battery"],
"function": "stemmedContains"
}

You will be able to match battery, batteries, batteries for sale, strong battery, etc.

Last type of match is logical match. It works the same way as InputSearchFilter logical match does.

Logical AND - Used when multiple conditions need to be met for rule to match Example:

{
"all": [
// nested match conditions
]
}

Logical AND - Used when one of the conditions need to be met for rule to match: Example:

{
"any": [
// nested match conditions
]
}

Exclude match - Used when you want to negate a match condition Example:

{
"not": {
// match condition
}
}

Hierarchy

  • InputSearchRuleMatch

Properties

Applies logical AND to nested rule match clauses. Matches if all of them match

Applies logical OR to nested rule match clauses. Matches if any of them match

everything?: boolean

If set to true, rule will always match. Skip this parameter if it's not needed, does not accept false value. Used to create global rules in dashboard

Expected values to be compared against. Rule matches if at least one of them matches

Applies logical NOT to rule match clause. Matches if nested clause does not match

param?: string

Param from search query from where the value will be extracted

value?: string[]

Expected values to be compared against. Rule matches if at least one of them matches

Generated using TypeDoc