Skip to content

Filters

Filters allow the refinement of search results, simplifying the product exploration process and helping customers to find the right products faster and more efficiently.

Filter types

Ecommerce Search has two filter types to narrow down search results:

Note

Filters can only be applied if they are added as Allowed Filters.

Term filter

Term filters are used to include or exclude items based on specific terms. For example, if a user is looking for a specific brand or product type, term filters can be applied to ensure that only items that match those criteria are displayed.

A term filter consists of a key specifying the field to filter, a list of terms, and a match type specifying how the filter should operate. If the match type is not specified, Any is used by default.

Match Type Behavior Default
Any Must match any of the filter values. Equivalent to logical OR. Yes
All Must match all of the filter values. Equivalent to logical AND.
None Must match none of the filter values. Equivalent to logical NOT.
Match type overview for term filters
Filtering for either blue or white
1
2
3
4
5
6
7
8
{
    "filters": {
        "color": {
            "values": [ "blue", "white" ],
            "match": "any"
        }
    }
}
Filter for both waterproof and wind-resistant
1
2
3
4
5
6
7
8
{
    "filters": {
        "weather": {
            "values": [ "waterproof", "wind-resistant" ],
            "match": "all"
        }
    }
}

Range filter

Range filters are ideal for numeric data where a user may be interested in items within a certain range. This could be price, size, weight, or any other quantifiable attribute. Range filters can be set with minimum and maximum values to define the bounds of the search.

A range filter consists of a key specifying the field to filter, from and to values, and a match type specifying how the filter should operate. Either from or to can be omitted, for an unbounded upper/lower range.

Match Type Behavior Default
Within Value must be within specified inclusive range. Yes
Match type overview for range filters
Filter within a range
1
2
3
4
5
6
7
8
{
    "filters": {
        "size": {
            "from": 41,
            "to": 43
        }
    }
}

Handling missing fields

Missing field behavior specifies how Ecommerce Search should handle documents that are missing the filter fields during searches. This is useful when using Unified search, which returns both products and content that do not share all fields. For example, content does not have a stock or price field, but products do.

When defining a filter you can specify the missing field behavior. The default behavior is ignoring the document.

Option Behavior Default
MatchDocument Documents with missing fields will be included.
IgnoreDocument Documents with missing fields will be filtered. Yes
Missing field behavior types for filters

Defining missing field behavior on domain filter

When searching with a domain filter on price, with MissingFieldBehavior set to MatchDocument, ECS will return both content and products. With MissingFieldBehavior set to IgnoreDocument only the products will be returned as the content doesn't have the price field.

Applying filters

Ecommerce Search has two main mechanisms for applying filters, facets and domain filters.

Filters can be represented by the following diagram:

Filtering

Filter type overview for predefined fields

Facets

Facets are user-facing and provide a way for shoppers to interact with the search interface to refine their results.

Facets are essentially attributes that can be used to dynamically narrow search results. They are typically displayed on the search results page and allow users to filter results based on categories such as color, size, brand, etc.

Ecommerce Search has two types of facets, which mirror the two available filter types:

  • A term facet lists all possible values for a given field. It also indicates whether the facet is selected or not, and which specific values from the facet are selected.

  • A range facet contains min and max specifying the value range of the products. It also shows the selected from and to.

Facets are applied by adding a filter that matches the configured context facet to the search query.

Warning

When resolving context facets, both the filter key, e.g. color, and the match type must match. If a filter in a query does not match any context facets, it will not work as a facet, but as a domain filter.

Facets must be created on a context before they can be used. Creating facets consists of the following steps:

  1. Ingest products with attributes
  2. Add the field you want to use for the facet as an allowed filter
  3. Add the field as a context facet on a given context
  4. Do a search that resolves to that context
Using facets in search request

Given a context with the following facets configured:

  • Term facet on Color field with Any match type.
  • Range facet on Price field with Within match type.
Search request
1
2
3
4
5
{
"segmentId": "b2c-dk-da",
"scopeId": "Browse",
"phrase": ""
}

Ecommerce Search returns the following facets.

Response
{
    "facets": [
        {
            "key": "COLOR_ATTRIBUTE_ID",
            "name": "Color",
            "facetType": "Term",
            "values": [
            {
                "count": 4,
                "isSelected": false,
                "key": "BLUE_ID",
                "name": "Blue",
            },
            {
                "count": 4,
                "isSelected": false,
                "key": "GREY_ID",
                "name": "Grey",
            },
            {
                "count": 4,
                "isSelected": false,
                "key": "ORANGE_ID",
                "name": "Orange",
            }
            ]
        },
        {
            "key": "Price",
            "facetType": "Range",
            "max": 1300,
            "min": 500
        }
    ]
}

It shows two facets; color and price. Each facet contains a key, which represents the attribute name, a facetType which specifies the type, either a Term or a Range. There is also the name, that is the display name of the facet.

The values, min, and max are values denoting the possible values in the dataset. In this case, it means that if a color filter is applied, the minimum and maximum price will change to the actual minimum and maximum price of the products with that color.

Domain filters

Domain filters are used to apply broad filtering rules that may not change often. For example only displaying products that are currently in stock or available in a particular region. Domain filters are usually predefined by the store's search configuration

Unlike facets, domain filters are not directly visible to the user, but are applied behind the scenes, determined by scope, to ensure that search results are relevant to the store's domain-specific rules.

Note

Content and products that are excluded by a domain filter will not be included in the calculation of Total hits, and will not be used in the calculation of facets.

Domain filters cover the following filter types:

Using domain filters

A commonly used domain filter could be CategoryIds, which might be pre-applied when searching from certain pages on your ecommerce site.

Filtering on predefined fields

Ecommerce Search has some predefined fields on content and products/SKUs. The following table provides an overview of filterable predefined fields. Note that not all of these have filtering enabled by default, see Allowed filters for additional information. It is also important to note that the field names are case sensitive.

Field Type Default Filterable
CategoryNames Term Yes
CategoryIds Term Yes
Price Range Yes
SearchableIds Term Yes
InStock Term Yes
Inactive Term No
Filter type overview for predefined fields
Filtering on the predefined field CategoryNames
1
2
3
4
5
6
7
8
{
    "filters": {
        "CategoryNames": {
            "values": [ "Makeup" ],
            "match": "all"
        }
    }
}