elasticsearch-module

1.0.0 • Public • Published

elasticsearch-module

A wrapper around functions of elasticsearch.

NPM

Install

$ npm install --save elasticsearch-module

Initializing

var esModule = require('elasticsearch-module')
    
esModule.init({
  baseUrl: 'http://youip:9200/'
});

Add index

var className = 'product';
var data = { 
    "objectId": "0001", 
    "user": "dilbert", 
    "postDate": "2011-12-15", 
    "body": "Search is hard. Search should be easy." ,
    "title": "On search"
};

esModule.add(className, data).then(function(result){
    //dosomething() ....
},function(err){
    //dosomethingElse() ....
});

Search

var className = 'product';
var _search = 'pretty' -d' { "query": { "fuzzy" : { "description" : "The solar system", "fuzziness": 2 } } }';
//var _search = 'q=body:Search';

esModule.add(className, _search).then(function(result){
    //dosomething() ....
},function(err){
    //dosomethingElse() ....
});

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i elasticsearch-module

Weekly Downloads

1

Version

1.0.0

License

ISC

Last publish

Collaborators

  • wahengchang