Achyut Kr Deka Achyut Kr Deka - 1 year ago 186
Node.js Question

ElasticSearch with Express framework

I want to built a application and a api which will mainly retrieve a resource, Now I have heard a lot about

and I know little bit Nodejs and Express framework. But I don't know how will I integrated ElasticSearch with Express framework.

Answer Source
  • 1st download ElasticSearch
  • Inside your project / Express framework directory download ElasticSearch express driver using npm install elasticsearch --save
  • Run ElasticSearch Instance, By default it runs on the port 9200
  • To use that module, simply create a client instance

    var elasticsearch = require('elasticsearch');
    var client = elasticsearch.Client({
      host: 'localhost:9200'
      index: 'books',
      type: 'book',
      body: {
        query: {
          multi_match: {
            query: 'express js',
            fields: ['title', 'description']
    }).then(function(response) {
      var hits = response.hits.hits;
    }, function(error) {
  • Helpfull Link

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download