Tuesday 28 February 2017

ElasticSearch Module in DXA


In my last two blogs we have discussed how to create components by consuming the data from Elasticsearch and then how to index data in Elasticsearch when publishing components.

Today,We are going to discuss and create Elasticsearch module in DXA which will have following features .DXA Modules allows us to extend its Functionality via creating new modules. Here we can create new modules which gives us flexibility & re-usability.

Features and Advantages :- 

  • Free text search .
  • Tag based filtering.
  • Lighting fast response powered by Elasticsearch.
  • Pagination and sorting based on fields.
  • Article detail page.

In order to use the Elasticsearch module we need to setup the storage extension and Elasticsearch which we already discussed in my previous blog here.
Once that is done using Elasticsearch module in DXA we can search the content from Elasticsearch and render on DXA based application .

Let's discuss the CMS part first.
Elasticsearch Module structure 


  1. Define module's folder structure
  2. DXA gives us predefined structure where we can keep all the building blocks of the module.
  3. For each new DXA module, we need to create a new folder in Modules Folder
  4. The name of folder is usually module name.

Next is creating the Schema and Component Templates. I have create dynamic components and index them in Elasticsearch and render on the DXA based web application.


  1. Publish all the dynamic components and index them in Elastic.
  2. Create new area in you DXA web Application.
    DXA Module
  3. We can call Elastic RESTFul API to get the data.
  4. Data will be returned in the form of JSON.
  5. Create model to deserialize the JSON.
  6. Let's search for the text SDL.
  7. Result can be further filtered based on tagging as well.
  8. Compare the search result with the data index in Elastic
    Elastic Search RESTFul API

.Happy Coding and Keep Sharing !!!

No comments:

Post a Comment