mongoosastic
v5.0.0
Published
A mongoose plugin that indexes models into elastic search
Downloads
11,292
Readme
Mongoosastic
Mongoosastic is a mongoose plugin that can automatically index your models into elasticsearch.
Getting started
- Install the package
npm install mongoosastic
- Setup your mongoose model to use the plugin
const mongoose = require('mongoose')
const mongoosastic = require('mongoosastic')
const 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)
const results = await User.search({
query_string: {
query: "john"
}
});
NOTE: You can also query Elasticsearch with any other method. Example:
curl http://localhost:9200/users/user/_search