# Faceted Search

> Source: https://docs.recombee.com/recipes/e-commerce/search/faceted-search

> For the complete documentation index, see [llms.txt](/llms.txt).

**Table of contents**

* [Introduction](#introduction)
* [Scenario Setup](#scenario-setup)
* [Logic](#logic)
* [Filters](#filters)  
   * [Facets](#facets)  
   * [Other Filters](#other-filters)
* [Requesting Search Results](#requesting-search-results)

# Faceted Search

![](/img/recipes/e-commerce/faceted-search.png) 

## Introduction

Faceted search is a widely used feature in e-commerce websites that enables users to filter products based on various attributes. It is essential for e-commerce websites with a large inventory to allow customers to quickly find products that match their interests/search etc.

Personalized search functionalities go beyond just parsing search queries. They also take into account a user's interaction history on the site, fostering a more tailored and intuitive browsing experience. By aligning search results with a user's behavior and preferences, businesses can enhance customer satisfaction, conversion rates, and overall sales.

## Scenario Setup

In the Recombee Admin UI, navigate to the **[Scenarios](/scenarios)** section and choose **Create Scenario**.

1. Enter a **Scenario ID**. Select a distinctive label for your recommendation scenario, such as _"faceted-product-search"_
2. Choose **Recommendation type** \- _[Search Items](/api#search-items)_

![Admin UI - Scenario Setup](/img/recipes/e-commerce/faceted-search-create-scenario.png)

There are typically many products matching the criteria and you want to offer the user more products as the user scrolls down.

Request the [Recommend Next Items endpoint](/api#recommend-next-items) to load subsequent products of interest.

## Logic

The [Logic](/recommendation_logics) defines the behavior of the recommendation engine.

* Choose the **[search:personalized](/recommendation_logics#search-personalized)** logic type from the **Universal Models**

You can adjust how much the results are biased towards the user (as opposed to strictly following the full-text results) by setting the `personalizationImpact` parameter.

![Admin UI - Logic](/img/recipes/e-commerce/faceted-search-logic.png)

## Filters

### Facets

The user filters the desired products by various facets such as _price_, _vendor_, _color_, _size_, and many more based on the particular type of products and selected category.

You can send the information about the user’s current selection using the [filter parameter](/api#search-items-param-filter) of the [Search Items](/api#search-items) endpoint. Only products satisfying the criteria will be returned.

For example, if the user has selected to search only within shoes by Nike that are red and size 42, the filter may look like:

ReQL

```
'category' == "shoes" and 'manufacturer' == "Nike" and 'color' == "red" and "42" in 'available_sizes'
```

If the user then adds a desired price range between 100 and 140 USD, the filter will become:

ReQL

```
'category' == "shoes" and 'manufacturer' == "Nike" and 'color' == "red" and "42" in 'available_sizes' and 100 <= 'price' <= 140
```

For more detailed information about how to construct the filters, please navigate to the [ReQL documentation](/reql).

### Other Filters

Available Products (Global Settings)

You always want to recommend only the products that are in stock. Therefore you need to apply a [**Filter**](/scenarios#filters) rule to allow only such products.

As it would be tedious and prone to error to add this rule to all the Scenarios, this rule shall be added to the [**Global Settings**](/scenarios#scenarios-in-admin-ui-global-settings), so it is always applied everywhere.

You can select a **predefined rule from the Recombee Library** to allow only the available products.

Depending on how you represent availability in the catalog, it can be **one of the following rules:**

* **Not deleted items** \- when you have a _deleted_ property (true/false)
* **Available items** \- when you have an _available_ property (true/false)
* **Items in stock \[Google Merchant\]** \- when you have a string _available_ property with _"in stock"_ as its value

![Admin UI - Global Settings - Filter](/img/recipes/e-commerce/filter.png)

## Requesting Search Results

Request the [Search Items endpoint](/api#search-items) of the Recombee API using an [SDK of your choice](/api_clients).

Don’t forget to set the [filter parameter](/api#search-items-param-filter) to allow only items that comply with the user’s selected criteria.