1.0.0 • Published 5 years ago
@cargatser/es_helper v1.0.0
ES_Helper
Elasticsearch little helper for most common operations.
Requirements
You will only need Node.js and @elastic/elasticsearch
Install
$ npm i es_helper
Configuration
INDEX_NAME, HOST and PORT are const variable inside es_helper.js
Default agg_size is 100
Example
$ var es_helper = require('es_helper')
$
$ // to get all buckets by field name
$ es_helper.getEsBucketsByFields(['FIELD_NAME', 'ANOTHER_FIELD_NAME'], 10, function(err, res) {
$
$ var aggResults = res.body.aggregations;
$
$ for (var aggTypeRes in aggResults) {
$
$ var singleAggBuckets = aggResults[aggTypeRes].buckets; // array
$
$ console.log("Results: ", JSON.stringify(singleAggBuckets, null, 4))
$ }
})
List of available commands
// to get list of aggs based by field(s)
getEsBucketsByFields(array, size, callback)
1.0.0
5 years ago