@hossny94/mongoosastic
v1.0.0
Published
A mongoose plugin that indexes models into elastic search. Based on mongoosastic v4.6.0 by James R. Carr. Added support for mongoose v6.X.X
Downloads
117
Readme
Mongoosastic
Mongoosastic is a mongoose plugin that can automatically index your models into elasticsearch.
Getting started
- Install the package
npm i @hossny94/mongoosastic
- Setup your mongoose model to use the plugin
var mongoose = require('mongoose')
, mongoosastic = require('@hossny94/mongoosastic')
, Schema = mongoose.Schema
var User = new Schema({
name: String
, email: String
, city: String
})
User.plugin(mongoosastic)
- Query your Elasticsearch with the
search()
method (added by the plugin)
User.search({
query_string: {
query: "john"
}
}, function(err, results) {
// results here
});