mongoosastic
TypeScript icon, indicating that this package has built-in type declarations

5.0.0 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i mongoosastic

Weekly Downloads

2,726

Version

5.0.0

License

MIT

Unpacked Size

101 kB

Total Files

38

Last publish

Collaborators

  • guumaster