elasticsearch-model
v1.0.2
Published
easy model builder for elasticsearch
Downloads
5
Readme
elasticsearch-model
easy model builder for elasticsearch
Getting Started
npm i elasticsearch-model
Usage
const { Client } = require('@elastic/elasticsearch')
const client = new Client({ node: 'http://localhost:30100' })
const {
t,
ESModel,
} = require('elasticsearch-model')
class Model extends ESModel {
custom () {
}
}
// createdAt and updatedAt are both required
const mapping = t.Mapping({
hello: t.KEYWORD,
createdAt: t.DATE,
updatedAt: t.DATE,
})
// Model
const name = 'doc'
const options = {
client,
index: name,
type: name,
mapping,
}
const model = new Model(options)
// model.updateMapping()
// Template
const name = 'log'
const options = {
client,
index: name,
type: name,
mapping,
}
const template = new Model(options)
const model = template.toModel('2019')
// template.updateTemplate()
Test
npm test