Skip to content

Commit

Permalink
fix(elasticsearch): remove ticket from index on delete
Browse files Browse the repository at this point in the history
  • Loading branch information
polonel committed Jun 9, 2019
1 parent 88bc20b commit 1b46ff4
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/elasticsearch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,23 @@ ES.testConnection = function (callback) {

ES.setupHooks = function () {
var ticketSchema = require('../models/ticket')
emitter.on('ticket:deleted', function (data) {
if (_.isUndefined(data._id)) return false

ES.esclient.index(
emitter.on('ticket:deleted', function (_id) {
if (_.isUndefined(_id)) return false

ES.esclient.delete(
{
index: ES.indexName,
type: 'ticket',
id: data._id.toString(),
refresh: 'true',
body: { deleted: true }
type: 'doc',
id: _id.toString(),
refresh: 'true'
},
function (err) {
if (err) winston.warn('Elasticsearch Error: ' + err)
}
)
})

emitter.on('ticket:updated', function (data) {
if (_.isUndefined(data._id)) return

Expand Down

0 comments on commit 1b46ff4

Please sign in to comment.