Include / Exclude Options
You can filter the available options for any facet/filter group via contains or regex match.
Applicable Facet Fields
Facet Field | Applicable To | Description |
---|---|---|
author |
articles |
Authors of articles. |
blog_list |
articles |
Blogs in which articles have membership. |
collections |
products |
Collections in which products have membership. |
option_0 |
products |
First variant option on product. |
option_1 |
products |
Second variant option on product. |
option_2 |
products |
Third variant option on product. |
product_type |
products |
Product Type on product. |
tags |
articles , products |
Third variant option on product. |
vendor |
products |
Vendor on product. |
Option Field | Allowed Values | Description |
---|---|---|
filter_exclude |
string | Exclude any items that match string value. Either treated as ‘contains’ or regex as described below. |
filter_include |
string | Exclude any items that match string value. Either treated as ‘contains’ or regex as described below. |
Matching Options for filter_exclude
, filter_include
The following options are applicable to all facet fields. See the code example further down.
Match Type | Match String |
---|---|
Match as ‘contains’ | If value provided is string, this will match as case insensitive ‘string contains x’. For example, filter every item that contains the text imported_at: . |
Match using regex | You may include a valid regex string for more specific matching patterns. Do not include the regex wrapper //ig . You must double escape forward slashes. Our regex options are case insensitive i , and NOT global g .For example, match sizes (^[xs|s |m|l|xl]$)|extra|small|medium|\large|[0-9] or match items that start with a dollar sign or a number \\$|[0-9] . Notice the double escaping here. We must double escape because we lose one escape character when passing around the object 🤷♂️ |
*https://regexr.com/ is a fantastic tool to test your regex.
~CE
<script>
window.sx_results = {
options: {
facets: {
author: {
filter_include: 'rick|karen' // include only authors containing "rick" or "karen"
}
}
}
}
</script>