Filtering

Let customers narrow down products by attributes, categories and price with the Search and Category APIs.

Last updated

On this page

Overview

Product filtering helps customers narrow down product collections and find precisely what they are looking for. Fast, optimized filters are crucial for customer satisfaction.

Athena XAI provides highly optimized filters with response times consistently below 150~250ms. Customers can refine product collections by color, size, price and every stored attribute.

How to filter your data

Athena XAI includes default filters such as price, price range, category and stock status. These filters require a correctly defined set of data.

Additional filters are generated from attribute feeds, where each attribute (for example, color or size) represents a filter.

Filtering by attributes

In the Settings -> Filters section of the Athena XAI Dashboard, you can customize filters by changing their Type, Visible Name and Order.

After you configure filters, data must be reindexed.

Athena XAI supports two types of data filtering: multiple select filters and single select filters. Specify the filter type in the Settings -> Landing Page section, under the Multiple Select Filters block.

You can list filters for landing or category pages using the filters field in the response of the Category API or the Search API. Each filter includes a unique type and an array of options.

This example shows how Athena XAI returns filters:

JSON
{
   "products": {
      "results": [
           ...
      ]
      "filters": [
         {
            "title": "Color",
            "type": "color",
            "array": [
               {
                  "option_value": "50",
                  "option_id": "50",
                  "option_key": "color",
                  "option_label": "Blue",
                  "attribute_id": 93,
                  "selected": false,
                  "count": 36,
                  "type_id": "1",
                  "hax_code": "#1857f7",
                  "url": "https://example.com/athena/?q=m&color=50",
                  "url_path": "/?q=m&color=50",
                  "url_params": {
                      "q": "m",
                      "color": "50"
                  }
               }
            ]
         },
         {
            "title": "Size",
            "type": "size",
            "array": [
               {
                  "option_value": "167",
                  "option_id": "167",
                  "option_key": "size",
                  "option_label": "S",
                  "attribute_id": 144,
                  "selected": false,
                  "count": 98,
                  "type_id": "0",
                  "hax_code": "",
                  "url": "https://example.com/athena/?q=m&size=167",
                  "url_path": "/?q=m&size=167",
                  "url_params": {
                      "q": "m",
                      "color": "167"
                  }
               }
            ]
         }
      ]
      ...
}

To filter a product collection, add an option_key and an option_value to the required fields of the request:

  • To filter by multiple attributes, include additional data in the request body.
  • To filter by multiple option values for the same key, separate them with an underscore character _.

These rules also apply to the Category API.

Search API request

JSON
{
   "q": "Yoga",
   "token": "{{ website_token }}",
   "color": "50_57",
   "size": "167"
}

Category API request

JSON
{
   "category": "14",
   "level": "2",
   "token": "{{ website_token }}"
   "color": "blue_purple",
   "size": "s"
}

Filtering by categories

Athena XAI filters by categories using its own logic based on branching. Categories are organized into levels, so customers filter data level by level.

For instance, take the categories Men and Women, each with a subcategory Pants. Athena XAI first displays the Men and Women categories. After a filter is applied, it shows only the relevant Pants category.

For this to work correctly, the category feed must follow the rules on the Category Feed page.

This example shows how the Athena XAI API and Category API return data for category filters. When a category filter with type category1 is active, the APIs return category filters at a deeper level with type category2.

JSON
{
   "products": {
      "results": [
           ...
      ]
      "filters": [
         {
            "visibleName": "Category",
            "typeField": "category1",
            "array": [
               {
                  "original_value": "11",
                  "label": "Men",
                  "count": 24,
                  "link": "/?q=pant&category1=11",
                  "url": "http://magento.local.com/athena/?q=pant&category1=11"
               },
               {
                  "original_value": "20",
                  "label": "Women",
                  "count": 13,
                  "link": "/?q=pant&category1=20",
                  "url": "http://magento.local.com/athena/?q=pant&category1=20"
               }
            ]
         }
      ]
      ...
}

To filter by category, add a field to the request body, where the key is a type and the value is an original value of the category option.

Search API request

JSON
{
   "q": "Yoga",
   "token": "{{ website_token }}",
   "category1": "11",
   "category2": "54"
}

Category API request

JSON
{
   "category": "14",
   "level": "2",
   "token": "{{ website_token }}",
   "category3": "87"
}

Filtering by price

You have two options: a custom price filter, or the Athena price range.

Custom price filter

Create and customize the price filter with rules in the Settings -> Filters section.

Format to control your price filter:

TEXT
startrange1,endrange1,Label1
startrange2,endrange2,Label2
startrange3,endrange3,Label3

Example of the format with real values:

TEXT
0,40,Less than $40
40.01,80,$40 and $80
80.01,1000,Greater than $80

Once you have created and configured a price filter, use it like an attribute filter. The same rules apply.

Athena price range

Before you filter by price, make sure that product prices are accurately stored and follow the pricing rules. In the request, include a price field with a price range value.

Search API request

JSON
{
   "q": "Yoga",
   "token": "{{ website_token }}",
   "price": "20.00-32.00"
}

Category API request

JSON
{
   "category": "14",
   "level": "2",
   "token": "{{ website_token }}",
   "price": "20.00-32.00"
}

Response

The response includes the filtered products and additional fields within the collection_price field:

  • lowest_price_with_filters and highest_price_with_filters are the range border values.
  • lowest_price and highest_price are the minimum and maximum prices for products without the price filter, which simplifies price range management.
JSON
{
   "data": {
      "products": {
           …
           "collection_price" : {
               "lowest_price_with_filters": "20.00",
               "highest_price_with_filters": "32.00",
               "lowest_price": "14.99",
               "highest_price": "89.99"
           },
          …
      }
      ...
}