From Online Retailer to Geographically Distributed Marketplace – with Elastic
In late 2011, SA Florist joined the myriads of hopeful dot-com billionaires by launching an e-commerce start-up with the aim of revolutionising the floral industry. While our initial website contained a few advanced B2B features specifically developed for the florist industry, it remained a largely stock-standard e-commerce implementation.
It’s hard to remember a world without e-commerce. Almost any product nowadays can be purchased over the internet and delivered to one’s home – flowers are no exception.
For merchants, creating an online presence is now easier than ever. There are a plethora of providers who offer feature-rich out-of-the-box e-commerce solutions. Some of these solutions can be set up and made ready to transact in minutes. For the SME (subject matter expert) who requires a deeper level of customisation, there are free open-source frameworks that can be modified and scaled to enterprise levels with relative ease.
The mass proliferation of e-commerce technology and its subsequent mass adoption have led to a situation, at least in our sector, where the e-commerce ‘space’ is heavily saturated. Consumers now have more providers to choose from than ever. On the other hand, differentiation between competing providers remains low.
The South African online flower market is dominated by a single incumbent who, until fairly recently, remained largely unchallenged. Over the years, competitors have entered the market but none have managed to make any waves big enough to seriously challenge the incumbent’s hold.
Towards a Marketplace
In 2014, SA Florist secured a seed series funding investment of ZAR 3 million (roughly 350000 USD) from the South African franchise of Dragons’ Den. This allowed us to ramp up our operations. What followed was a complete overhaul of our business model, heavily relying on Elastic to enable this rapid change.
We realised that if we wanted to become a serious player in the market, we couldn’t do things the same way as our competitors. We would have to differentiate ourselves and offer consumers a far better value proposition.
After much research, and encouraged by the high-profile successes of companies such as Uber and Airbnb, we decided to pivot our business from an online retailer into a geographically distributed marketplace.
Figure 1: Functionality of the geo-marketplace in order from 1-6 (1=Home, 2= Search, 3=Results, 4=Sellers List View, 5=Sellers Map, 6=Product)
Elastic was the obvious choice of technology to power our marketplace. Several factors led to this decision:
- Elastic is easy to set-up and upgrade
- An Elastic node can be set up in under 5 minutes.
- Upgrading a node is just as simple.
- Elastic works as well in a Microsoft Windows environment as it does in a Linux environment.
- Elastic is built with Java – so it can run on anything that runs Java.
- The Elastic package for Microsoft Windows is accompanied by easy-to-use command line tool that makes installing additional plugins a breeze. This tool also allows Elastic to be installed as a Windows service.
- Elastic has rich search capabilities.
- Elastic does geo really well.
- While Elastic scales horizontally very well, it works just as well in a lower volume environment (with the option to scale out later as needed).
- Elastic is open source.
- It is therefore free to install - no expensive license fees.
- Elastic has a healthy community of contributors.
In a .NET Environment
As a company that uses a Microsoft .NET / ASP.NET / C# / MVC / SQL Server based web application technology stack, integrating and working with Elastic as a data source is a pleasure.
- Elasticsearch.NET and NEST are client libraries that allow .NET applications to generate the JSON necessary to communicate with Elastic - this makes writing an Elastic request and interpreting the subsequent response very familiar (C#).
- Elastic requests and response are respectively mapped to and from CLR objects – NEST does all the heavy lifting.
- Debugging Elastic requests is easy with plugins such as Head and Inquisitor.
Where are you sending to?
As I mentioned earlier, our initial website contained a few advanced B2B features specifically developed for the florist industry. These B2B features allow florists (or other retailers who can’t ship their products nationally) to take orders in their shops for distant areas, and relay them to a florist nearby the recipient.
We extended the data structure underlying the B2B system, by adding to our code, a layer of JSON serializable data objects. The data objects were given a geo_point property that corresponds to the physical location of the florists’ shops. We then built an index management utility to CRUD our objects. A bit of MVC’ing later and voila! – a geographically distributed flower marketplace.
In order to filter by distances, Elastic needs geo coordinates, so we used Google’s APIs and an auto-complete lookup to verify and pinpoint customers' street addresses.
Version 1.0 of the marketplace took us about a month to take live. It took the time of two developers to accomplish this.
Features we Love
- Aggregations is the feature that we have used most abundantly in our implementation of Elastic.
- They are fairly easy to implement and are a powerful, fast and extendable way of returning real-time data analytics.
- We use the aggregations returned by Elastic to construct the search parameters of our marketplace. Users are then able to select parameters, including the destination to which they are sending, to see what is available in that area (see figure aboveas an example).
- Post-filtering has allowed us to return aggregations that are out of the scope of a user’s search parameter-bounded result set. Users can see what can be delivered from nearby areas and change their area search parameters accordingly.
- Function score
- Function score allowed us to easily implement a custom scoring model to suit our business requirements.
- Complex business rules – filter operators
- We have very specific and complex business rules that determine which products are available in any specific search.
- Using NEST and a bit of Groovy scripting, we were able to implement our business rules into the main search query filter with relative ease.
- Managing Indexes
- Inserting, updating and deleting documents from an index can be done in near real-time.
- There is no need to build a queue to manage these operations – Elastic can handle the load. (If performance ever becomes an issue, it’s time to scale horizontally by adding another node to your cluster.)
- It is as easy as that.
"We highly recommend Elastic. It has allowed us to transform our business in record time with minimal resources" - Jean Michel Gaud, Senior Developer, SA Florist.
Jean-Michel Gaud is the lead developer at SA Florist, a South African based start-up intent on disrupting the online flower market. Jean-Michel has been developing systems since 2008 (except for four years between 2010 and 2014 when he went back to university to study Information Systems). He resides in beautiful Cape Town, South Africa. When not writing code, he can usually be found on the mountain or at the beach.