Skip to content

SmallCharm/mongoosastic

 
 

Repository files navigation

Mongoosastic

CI workflow NPM version Coverage Status Downloads

Mongoosastic is a mongoose plugin that can automatically index your models into elasticsearch.

Getting started

  1. Install the package
npm install mongoosastic
  1. 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)
  1. 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

Documentation

View docs

About

Index Mongoose models into elasticsearch automatically.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 98.0%
  • JavaScript 1.3%
  • Other 0.7%