elasticsearch-extend

0.1.2 • Public • Published

elasticsearch-extend

npm version

Extended official elasticsearch module with ODM functions

Features

  • Compatible with official elasticsearch
  • ES6 syntax(generator, class, etc).

How to use

Init es connection:

const es = require('elasticsearch-extend');

es.connect({
    host: 'localhost:9200',
    log: 'info'
})
.then(function(){ ... })
.catch(function(error){ ... });

Once connected, register a model:

const UserModel = es.model('user', {
    username: { type: "string"},
    phone: { type: "string"}
});

Get a registered model:

const UserModel = es.model('user');

APIs

es.connect(params)

Connect to an elasticsearch server

es.isConnected

Indicate whether elasticsearch connected or not

es.model(modelName, mapping)

Register a model

es.model(modelName)

Get a model

Model APIs

model.createOne(params)

Create one document

model.list(params)

List documents

ToDos

  • More model APIs
  • Document APIs

Readme

Keywords

Package Sidebar

Install

npm i elasticsearch-extend

Weekly Downloads

8

Version

0.1.2

License

ISC

Last publish

Collaborators

  • hankchiu