You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

elastic-query

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elastic-query

build elasticsearch queries with self esteem

0.0.6
latest
Source
npmnpm
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

elastic-query

build elasticsearch queries the sane way

Install

npm install --save elastic-query

Motivation

the elasticsearch json query syntax pure pain

Setup

elastic-query expects both ES_URL and ES_INDEX environment variables to be definied

so you may have a config file that looks something like:

export ES_INDEX=events
export ES_URL=https://mysearch:9200

Usage

var Query = require('elastic-query')

// create a fresh query:
var q = new Query

// chain modifications:
q.size(10) 
q.queryString('event.type:foo')
q.range('timestamp', 1467817775660, 1467817785860)
q.agg('min', 'min_timestamp', 'timestamp')
q.agg('max', 'max_timestamp', 'timestamp')

// call it!
q.fetch() // no args returns a promise

q.fetch(function(err, res) {
  // or with callback 
})

Tests

npm test

Keywords

elasticsearch

FAQs

Package last updated on 30 Sep 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts