0.0.1 • Published 6 years ago
es.io v0.0.1
ElasticSearch - NodeJS
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 ... :heart_eyes:
Install
Install used NPM.
$ npm i es.io
For BigData execute Scroll.
es.scroll('/index/_doc/_search', {})
This is very good :sunglasses:
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
0.0.1
6 years ago