UNPKG

mongoose-elasticsearch-xp

Version:

A mongoose plugin that indexes models into Elasticsearch 2 / 5 (an alternative to mongoosastic)

24 lines (18 loc) 487 B
'use strict'; const elasticsearch = require('elasticsearch'); module.exports = function(options) { const opts = {}; if (Array.isArray(options.hosts)) { opts.host = options.hosts; } else { opts.host = { host: options.host || '127.0.0.1', port: options.port || 9200, protocol: options.protocol || 'http', auth: options.auth || null, keepAlive: false, }; } opts.log = options.log || null; return new elasticsearch.Client(opts); };