Elasticsearch began as a full-text search solution, but its evolution has brought it to the point where it is a top contender for building e-commerce product search.

Continue reading below to find out why.

 

Editorial note: Neil Alex is a freelance data consultant with expertise in Lucene and Elasticsearch. We asked him to write about his use of Elasticsearch in the E-commerce context. This is the first post in the series. — Mark Brandon

The most important reasons to build your e-commerce product solution with Elasticsearch include the following:

  • Simplicity in building filters, facets, and aggregations
  • Incredibly fast response times, even if you have a large data volume
  • Ease in maintaining 100% uptime
  • Simplicity and efficiency in making changes on your product information
  • The ability to make geo-localized searches
  • Ease in collecting analytic information, giving you valuable insights on the performance of your products

All of these are fantastic reasons, but for the e-commerce use case, the first one is perhaps the most important: the extreme simplicity in building filters, facets, and aggregations.

Research is emphatically clear: you will significantly boost your conversion rate when you enable users dto rill down to a point where they can choose from a manageable product set. It’s a fact: faceted searchers are 3 times more likely to become buyers than are other, less structured browsers.

You may also be painfully aware that the out-of-box search solutions like those on Magento, Prestashop, Zencart, and others are woefully inadequate.

In this series of posts, we want to share our enthusiasm for using Elasticsearch in e-commerce. We’ll start by building a simple e-commerce back end, although we won’t cover well-known features such as autocomplete/auto-suggest and highlighting. From the simple platform that we are going to create, we’ll focus on faceting and aggregations and look at ways of seeking important business insights with Elasticsearch.

Setting up our Back End

(If you need a quick tutorial on setting up your Qbox instance, check out Mark Brandon’s post, Provisioning Elasticsearch Clusters from the Qbox Dash.)

First, we are going to index some data, which for e-commerce merchants is our product information. Let’s say we have an online store of electronic goods like laptops, tablets, and mobile phones.

For this purpose, we will first create an index and define the mappings for our fields. I attempt to create an index named ‘ecomercedata’ of the type gadgets. Although elasticsearch is schema-less (in that it can automatically define the field mappings from the document that we toss to the Elasticsearch instance), let me include the snippet I used to create the index and mappings for reference.

Script to define the index :“>

curl -X PUT 'http://localhost:9200/ecomercedata' -d '{
  "index": {
    "number_of_shards": 1,
    "number_of_replicas": 1
  },
  "analysis": {
    "analyzer": {
      "flat" : {
        "type" : "custom",
        "tokenizer" : "keyword",
        "filter" : "lowercase"
      }
    }
  }
}'

Script to define the field mapping :

curl -X PUT "http://localhost:9200/ecomercedata/gadgets/_mapping" -d '{
  "gadgets" : {
    "properties" : {
      "category" : {
        "type" : "String"
      },
      "brand" : {
        "type" : "String"
      },
      "name" : {
        "type" : "String"
      },
      "rating" : {
        "type" : "Integer"
      },
      "dateOfRelease" : {
        "type" : "date",
        "format" : "YYYY-mm-dd"
      },
      "prize" :  {
        "type" : "Double"
      },
      "piecesSold" : {
        "type" : "Integer"
      }
    }
  }
}'

Doc1 :

{ "name" : "MacBook Pro", "category" : "Laptop", "brand" : "Apple", "rating" : 9, "prize" :  1299.00, "piecesSold" : 9500,  "dateOfRelease" : "2005-02-01"}

Doc2 :

{"name" : "MacBook Air",  "category" : "Laptop", "brand" : "Apple",  "rating" : 8,  "prize" :  1099.00,  "piecesSold" : 8700,   "dateOfRelease" : "2006-05-01"}

Doc3 :

{"name" : "ATIV Book",  "category" : "Laptop",  "brand" : "Samsung",  "rating" : 8,  "prize" :  1899.00,  "piecesSold" : 3500,   "dateOfRelease" : "2014-05-01"}

Doc4 :

{"name" : "Inspiron",  "category" : "Laptop",  "brand" : "Dell",  "rating" : 6,  "prize" :  700.00,  "piecesSold" : 4600,   "dateOfRelease" : "2008-03-01"}

Doc5 :

{"name" : "Ipad",  "category" : "Tablet",  "brand" : "Apple",  "rating" : 9,  "prize" :  600.00,  "piecesSold" : 9500 ,  "dateOfRelease" : "2005-07-01"}

Doc6 :

{"name" : "Galaxy Tab",  "category" : "Tablet",  "brand" : "Samsung",  "rating" : 8,  "prize" :  550.00,  "piecesSold" : 8500 ,  "dateOfRelease" : "2007-07-01"}

Doc7 :

{"name" : "Lumia",  "category" : "Mobile",  "brand" : "Nokia",  "rating" : 6,  "prize" :  50.00,  "piecesSold" : 12000 ,  "dateOfRelease" : "2009-03-01"}

Doc8 :

{"name" : "Iphone",  "category" : "Mobile", "brand" : "Apple",  "rating" : 8,  "prize" :  60.00,  "piecesSold" : 28000 ,  "dateOfRelease" : "2002-03-01"}

Doc9 :

{"name" : "Xperia",  "category" : "Mobile",  "brand" : "Sony",  "rating" : 8,  "prize" :  70.00,  "piecesSold" : 24000 ,  "dateOfRelease" : "2004-03-01"}

Setting Up Faceting

Intuitive searches are a major requirement of any e-commerce platform. If you’re unfamiliar with it, faceted search refers to a method of navigation that allows users to filter data. If you think about how Amazon organizes their search results with filters on the left side, then you have a good idea. his term can also be interchanged with other terms such as “guided navigation” or “layered navigation.” This user experience by itself will increase your conversions, especially if you combine it with a search box. Notice the left hand side of the page in the figure below, which shows how Amazon allows users to make a faceted search by choosing from among the lists of facets and filters.

amazon1.png

Facets allow you to have an overview of your query that corresponds to the summary data within its result set. Let’s say that you search for a laptop. You probably would’ve noticed the counts of entries that fall in that particular group alongside the facet. This lets you guide your search in such a way that you can refine your result set to include or eliminate results according to your choice. You’d also probably notice a distribution histogram like that of a price histogram that lets you select your product that falls in that particular price range.

As faceting evolves and product catalogs become more complex, “nested faceting” has become something of a necessity. Nested faceting — or hierarchical faceting — refers to a facet located within another facet. Nesting a facet inside another would give faceting yet another dimension, enabling a user to go on to add more filters (which is a logical OR on the results) to any level they prefer.

Nested faceting helps limit the space and complexity of the drill-down experience. When it comes to conversions, simple is best. Consider the nested facets in the figure above where, beneath the LCD TVs facet, you have separate facets for Display Size, Resolution, and Screen Type. These filters will usually change to correspond to the product(s) that the user selects.

Prior to Elasticsearch v1, creating nested faceting was difficult. But the uber-powerful Aggregations feature changes this. Think of aggregations as “facets of facets.” If you’re new to the concept, take a look at An Introduction to Elasticsearch Aggregations by Qbox developer Michael Lussier. If you’ve started the process with facets and need to migrate to aggregations, then check out Brad Simmons’ post, Migrating from Facets to Aggregations.

In Part 2 of this blog post series, we will explore using aggregations to create a nested or hierarchical faceting experience in the e-commerce context. We hope you’ll check it out.