How to use elasticsearch

Comprehensive elasticsearch code examples:

How to use elasticsearch.Clinet:

1
2
3
4
5
6
7
8
9
10
11
12
var moment = require('moment');
//import {compareAsc, format} from 'date-fns';


//var elasticsearch = require('elasticsearch');


//var client = new elasticsearch.Clinet({
//  host: 'https://vpc-kibanaes-7hf47ssvnzvtrlmkokag3l4adm.us-east-2.es.amazonaws.com',
//  log: 'error'
//});
const { Client } = require('elasticsearch')

How to use elasticsearch.Client:

800
801
802
803
804
805
806
807
808
809
  return esClient
}
const esHost = config.get('ES.HOST')
// AWS ES configuration is different from other providers
if (/.*amazonaws.*/.test(esHost)) {
  esClient = elasticsearch.Client({
    apiVersion: config.get('ES.API_VERSION'),
    hosts: esHost,
    connectionClass: require('http-aws-es'), // eslint-disable-line global-require
    amazonES: {