es.io

0.0.1 • Public • Published

ElasticSearch - NodeJS

NPM - ElasticSearch IO

This library executes Query DSL (Domain Specific Language) based on JSON, of extremely simple format to comunicate with the ElasticSearch. Builder to execute "sync" (synchronous) It's developed to be used in any framework, ExpressJS, KoaJS, Restify, etc... Also contain a Scroll function for the execute of paginate in queries. Use Axios (dependence) for communication REST.

This library support ALL methods GET, PUT, POST, DELETE ... 😍

Install

Install used NPM.

$ npm i es.io

For BigData execute Scroll.

es.scroll('/index/_doc/_search', {})

This is very good 😎

For custom execute.

es.execute('GET' '/index/_doc/_search', {})

For GET execute.

es.get('/index/_doc/_search', {"size":9})

For PUT execute.

es.put('/index/_doc/:id', {"field":"value"})

For POST execute.

es.post('/index/_doc/:id', {"field":"value"})

For DELETE execute.

es.delete('/index/_doc/:id')

Library example

Example of any use.

// package
var es=require('es.io');
 
// elasticsearch
es.host='http://127.0.0.1:9200';
 
// app
(async ()=>{
 
  // debug
  console.log('Start!');
 
  // data
  es.result=await es.execute('GET', '/_stats', {}).then((result)=>{
    return result;
  });
 
  // debug
  console.log(es.result);
 
  // debug
  console.log('Finish!');
 
})();

ExpressJS - Example

Example of use with ExpressJS.

// package
var express=require('express');
var es=require('es.io');
 
// elasticsearch
es.host='http://127.0.0.1:9200';
 
// express
const app=express();
 
// example
app.get('/', async (req, res)=>{
 
  // data
  es.result=await es.execute('GET', '/_stats', {}).then((result)=>{
    return result;
  });
 
  // response
  res.json(es.result);
 
});
 
// app
app.listen(3000, ()=>console.log('es.io - Express'));

KoaJS - Example

Example of use with KoaJS.

// development

Restify - Example

Example of use with Restify.

// development

Readme

Keywords

Package Sidebar

Install

npm i es.io

Weekly Downloads

4

Version

0.0.1

License

unlicense.org

Unpacked Size

7.46 kB

Total Files

8

Last publish

Collaborators

  • thiagoeti