Sitecore Commerce: Elasticsearch driven Faceted Search/Navigation for eCommerce – Part 2

In Part 1 of this series we described the faceted search/navigation search pattern with an example from the website. We also installed Elasticsearch and Kibana. In this post we’ll be setting up the index, define the data structure, create a mapping document, load some sample data and construct a query for faceted search/navigation.

Creating the Index
To store and index data in elasticsearch we first need to create an index. The index can have specific settings associated with it and can be defined in the body of the request. We will set the number_of_shards and number_of_replicas to 1 for simplicity and to avoid an issue where the result item scores can be incorrect with multiple shards and very small dataset.


PUT productitems
"settings": {
"number_of_shards": 1,
"number_of_replicas": 1


"acknowledged": true,
"shards_acknowledged": true,
"index": "productitems"

Defining the data structure
We have a concept of the Product which describes the product being sold. It has a Product Id, Name, Description, Image, Specifications, etc. The product may come in different variations, for example color or sizes in case of clothing products. A variation is represented by Variant entity. A Variant is what is actually inventoried, sold, and shipped when a customer purchases a product. It has a SKU, Price, Stock, Variant Image and other Variant specific attributes (color, size, etc.) associated with it. In our example from Part 1, we performed a faceted search for Red and Orange Jackets and the results came back with the images showing the appropriate colors. To be able to achieve this we need to index the Variants instead of the Products. Doing this brings up a problem though. Now if you searched for Jacket without the color facet selected you will get all Variants for a Product showing up in the results. This is not an ideal experience but thankfully there is a way to fix it which I’ll describe shortly.

The following Product->Variants structure represents a Color-Size attribute combination typical of a clothing product.

Product: Men’s Venture 2 Jacket

  • Variant: Red-Small
  • Variant: Red-Medium
  • Variant: Red-Large
  • Variant: Blue-Small
  • Variant: Blue-Medium
  • Variant: Blue-Large
  • Variant: Yellow-Small
  • Variant: Yellow-Medium
  • Variant: Yellow-Large

A JSON representation of such a hierarchy would look something like this:

Sitecore Commerce: Elasticsearch driven Faceted Search/Navigation for eCommerce – Part 1

This will be a series of posts on how to make Elasticsearch work with Sitecore in an eCommerce scenario. Elasticsearch is a great search engine but some work needs to be done to configure it to the specific use case of an eCommerce Faceted Search/Navigation scenario. In this first post we’ll be focusing on installing the Elasticsearch instance. In the following posts we’ll be defining the data mapping, inserting some test data and building a query suitable for Faceted Search/Guided Navigation and finally making Sitecore talk to Elasticsearch.

Faceted Search/Navigation, also known as Guided Navigation is a technique which extends the traditional full-text search with a faceted navigation system. It allows the users to refine or narrow down the product search result set using filters based on faceted classification of the product records. The search and navigation user interface is built such that each incremental filtration restricts the filters further and narrows down the results quickly. The user is also shown the count of products in each of the available facet constraints. For example, if the user is searching for a T-Shirts and the T-shirts come in Red, Green, and Blue color. Here Color would be the dimension and the values (Red, Green and Blue) would be facet constraints and the user would be shown how many of the Red (20), Green (12), Blue (10) products are available. Any constraints with 0 items available would be excluded from the UI as it would lead to a zero results page.

The products have dimensions or facets defined on them such as Brand, Color, Size, Categories, Physical Dimensions, Price, etc. A faceted search system classifies each Product along multiple explicit dimensions/facets which enables the search results to be accessed and ordered in multiple ways rather than in a single, pre-determined, taxonomic order. Increasing number of modern eCommerce sites now use the faceted search/navigation pattern and it has become a well understood eCommerce user experience but proper care must be taken during information architecture design of the site to support Faceted Search.

Here is a screenshot from as an example that uses faceted navigation. The products on the northface site have category, color, size, price, and activity as facets. See the annotations on the screenshots for the facets and the constraints UI as well as the commonly used item count feature. The UI also allows sorting by Relevance, Price, Rating, etc. Also note that the display images for the search results reflect the color facet constraint (Red and Orange). We are going to need to index the product data in a certain way to be able to support this.

Installing Elasticsearch 6.4.2 (windows command line way)

Install Java
The specific version of elasticsearch we will be installing need version 9. Download and install java from Oracle will annoyingly make you signup and login to be able to download this.

Install Elasticsearch

  • Download the latest elasticsearch version (6.4.2 as of this writing) from
  • Unblock, Extract and Copy the downloaded files to c:\elasticsearch-6.4.2
  • Run the elasticsearch batch file from C:\elasticsearch-6.4.2\bin>elasticsearch.bat
  • Check if elasticsearch responds on port 9200 http://localhost:9200/

Install Kibana
We’ll be using the DevTools from Kibana to interact with the elasticsearch instance.

  • Download from
  • Unblock, Extract and Copy the downloaded files to C:\kibana-6.4.2-windows-x86_64
  • This will take longer to download and extract kibana as it’s a larger download and has lot more files.
  • C:\kibana-6.4.2-windows-x86_64\bin>kibana.bat
  • Check if Kibana Responds at http://localhost:5601

Testing the Installtion

  • Open kibana from http://localhost:5601 and go to the DevTools sections
  • In the left hand pane of the Console area Type “GET /” and hit the green play button to run the query.
  • You should see the elasticsearch cluster information returned in the right hand pane.

In the next post we’ll create the index, define the Data Mapping, load some test data and construct a query suitable for our needs.