Get unlimited public & private packages + team-based management with npm Teams.Learn more »

elasticclient

0.1.0 • Public • Published

elasticclient

js elasticsearch client

var elastic = require('elasticclient');
 
var es = elastic();
// defaults to
// var es = elastic(9200, 'localhost');
// where
// var es = elastic(port, host);
 
// search at different levels
es.search(query, callback);
es.index('twitter').search(query, callback);
es.index('twitter').type('tweet').search(query, callback);
 
// search using query string
es.search('hello world', function(err, res, hits) {
  console.log(hits);
});
 
// search using ElasticSearch JSON query format
es.search({
  query: {
    filtered: {
      query: {
        query_string: {
          query: 'some query string here'
        }
      },
      filter: {
        term: { 'user' : 'kimchy' }
      }
    }
  }
}, function(err, res, hits) {
  console.log(hits);
});

Keywords

none

Install

npm i elasticclient

DownloadsWeekly Downloads

2

Version

0.1.0

License

none

Last publish

Collaborators

  • avatar