Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mongoosastic/mongoosastic
Index Mongoose models into elasticsearch automatically.
https://github.com/mongoosastic/mongoosastic
elastic elasticsearch elasticsearch-queries javascript mongodb mongoose nodejs
Last synced: 2 days ago
JSON representation
Index Mongoose models into elasticsearch automatically.
- Host: GitHub
- URL: https://github.com/mongoosastic/mongoosastic
- Owner: mongoosastic
- License: mit
- Created: 2014-10-24T16:44:30.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2023-03-07T16:23:05.000Z (almost 2 years ago)
- Last Synced: 2024-10-29T15:19:08.661Z (about 2 months ago)
- Topics: elastic, elasticsearch, elasticsearch-queries, javascript, mongodb, mongoose, nodejs
- Language: TypeScript
- Homepage: https://mongoosastic.github.io/mongoosastic/
- Size: 1.68 MB
- Stars: 1,071
- Watchers: 27
- Forks: 330
- Open Issues: 22
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Authors: AUTHORS
Awesome Lists containing this project
README
# Mongoosastic
![CI workflow](https://github.com/mongoosastic/mongoosastic/actions/workflows/ci.yml/badge.svg)
[![NPM version](https://img.shields.io/npm/v/mongoosastic.svg)](https://www.npmjs.com/package/mongoosastic)
[![Coverage Status](https://coveralls.io/repos/mongoosastic/mongoosastic/badge.svg?branch=master&service=github)](https://coveralls.io/github/mongoosastic/mongoosastic?branch=master)
[![Downloads](https://img.shields.io/npm/dm/mongoosastic.svg)](https://www.npmjs.com/package/mongoosastic)Mongoosastic is a [mongoose](http://mongoosejs.com/) plugin that can automatically index your models into [elasticsearch](https://www.elastic.co/).
## Getting started
1. Install the package
```bash
npm install mongoosastic
```2. Setup your mongoose model to use the plugin
```javascript
const mongoose = require('mongoose')
const mongoosastic = require('mongoosastic')
const Schema = mongoose.Schemavar User = new Schema({
name: String,
email: String,
city: String
})User.plugin(mongoosastic)
```3. Query your Elasticsearch with the `search()` method (added by the plugin)
```javascript
const results = await User.search({
query_string: {
query: "john"
}
});
```*NOTE*: You can also query Elasticsearch with any other method. Example:
```bash
curl http://localhost:9200/users/user/_search
```## Documentation
[View docs](https://mongoosastic.github.io/mongoosastic/)