eCommerace with Elasticsearch


Online shopping has been a core application for the Web since the mid-1990s when the Internet became available to the general public. This article discusses how the open source Elasticsearch database and the Amazon Web Services (AWS) Elasticsearch Service can be used as the foundation for an online shopping website.

To illustrate this application of Elasticsearch, this article discusses a demonstration application, written in Java. This application is implemented using the Spring framework (Spring Boot and Spring MVC).

published on the website.

  • Amazon Web Services documentation and blog posts on writing Java code to use Elasticsearch and signed HTTP.
  • Lots of Google searches to answer questions whose answers I could not find in the above references.
  • The book Elasticsearch in Action is very useful in understanding the capabilities of Elasticsearch and its architecture. As with most Manning books, the writing quality is high and I recommend reading the first five chapters of this book.

    Unfortunately, there are several problems with Elasticsearch in Action as a reference for developing software that uses Elasticsearch. The book is based on Elasticsearch version 2.X. At the time this article was written Elasticsearch is on version 6.X.

    There have been significant changes in Elasticsearch between 2.X and 6.X. Some of the queries and other operations described in the book do not work with Elasticsearch version 6.X.

    The Elasticsearch architecture has also changed. For example, in Elasticsearch in Action the authors state that there can be multiple types per index. Later versions of Elasticsearch allow only one type per index, making indices and types equivalent.

    In Elasticsearch in Action most operations are described in terms of command-line curl operations. For example, a search operation, from Elasticsearch in Action, is shown below.

    % curl 'localhost:9200/get-together/group/_search?pretty' -d '{
    "query": {
    "query_string": {
    "query": "elasticsearch"

    For the Java developer there are few resources to guide the development of Java code for Elasticsearch outside of the Amazon documentation (which is often incomplete and fragmented).

    I hope that this article and the associated code on GitHub will provide a useful resource for Java developers. The HTTP and Elasticsearch code is independent of the Book Search demonstration application and you may freely use it in your own applications.

    Running the Book Search Application

    The Elasticsearch based Book Search application can be cloned from its GitHub repository.

    The Book Search application is built using the Spring framework (Spring Boot and Spring MVC). To build the application you will need to install the Spring Tool Suite (STS), which is a version of Eclipse customized for the Spring framework. The STS project uses Maven to load the necessary Java libraries.

    To run the application you will need an Amazon Web Services account and you will need to configure an Elasticsearch Service domain. You will also need to use Amazon’s IAM service to obtain an ID and a secret key for Elasticsearch Service full access. The ID and key should be added to the IElasticsearch Java Interface in the code base. You will also need to add your Elasticsearch end-point URL to the Interface.

    When you run the Book Search application it will create an index and load a mapping. You can load test data from the books.json file using the LoadESFromJSON utility program.

    The Book Search Application

    The Elasticsearch version of the book search application expands on the Book Search application that uses DynamoDB with the addition of an “Explore” page that showcases some of the features Elasticsearch. The “explore” tab is shown below. This tab allows the user to explore the book database by genre or publisher.

    The “genre” accordion tab is expanded to show the book genres, with their associated book counts.

    The “Search for a book” tab allows the user to search by author, title or title and author.

    The DynamoDB application requires an exact author name or book title. Since this version of the Boook Search application uses the Elasticsearch database, partial author names or titles can be used in the search. For example, entering the word “venice” in the title search dialog will return the books with “venice” in their title.

    Amazon Cloud Architecture, Spring and Elasticsearch Consulting

    Topstone Software has extensive experience building scalable web applications on Amazon Web Services. We can help you design your AWS application architecture to provide scalability and optimized cost.

    We designed and built the nderground social network. nderground is a social network designed for privacy and security. nderground has been live with close to 100% uptime for over three years.

    At Topstone Software we have experience building Spring framework applications that utilize a variety of AWS services. These include Elasticsearch, DynamoDB, S3, the Simple Email System and Elastic Beanstalk. We can provide the consulting help to speed your application development or we can develop applications to your specification.

    This article was originally published on the Topstone Software website. The original version can be found here.

    eCommerace with Elasticsearch was originally published in Hacker Noon on Medium, where people are continuing the conversation by highlighting and responding to this story.