Message:

Subscribe rss
Blog categories
All | Backendless features
How to Integrate Amazon Elasticsearch Service with Backendless
February 28, 2019 by Sergey Kukurudzyak

Amazon Elasticsearch Service (Amazon ES) is a service that can store a lot of data and provide a full text-based search, among other cool features. In this article, we’ll show you how to integrate Amazon ES with your Backendless project.

Save objects to Amazon ES

To save objects to the Amazon ES with Backendless you have to:

  1. Create an Amazon ES domain
  2. Create after event handlers in the Backendless console
  3. Download generated code
  4. Write JavaScript code to save objects

Once you have an Amazon ES domain, create the afterCreate  event handler:
Create Event Handler for Amazon ES

Download JavaScript code and open it the IDE of your choice.

Open package.json  and add http-aws-es , elasticsearch , and aws-sdk  dependencies so your file should be like the following:

Open coderunner.json  and exclude aws-sdk  as it is already added to the Backendless cloud:

Open the  afterCreate.js file and paste the following code:

Now, each time you create an object in a Backendless data table, it will be saved to the Amazon ES as well.

Search in Amazon ES

Let’s create a Backendless service to search in the Amazon ES cloud. To do this, add the esSearchService.js  file to the project that was created in the previous step.

Then run CodeRunner in the debug mode, or deploy the code.

Go to Backendless console and try to search:
Invoke Amazon Elasticsearch Service in Backendless

Closing

In this article, we used https://www.npmjs.com/package/http-aws-es which makes elasticsearch-js compatible with Amazon ES. To see  more options for using ES API, check out the ES documentation.

Share this post
Tweet about this on TwitterShare on FacebookGoogle+