Skip to content

Commit

Permalink
chore(elasticsearch): indexName
Browse files Browse the repository at this point in the history
  • Loading branch information
polonel committed May 23, 2019
1 parent 9ff2c14 commit 79742ee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/elasticsearch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,13 @@ ES.rebuildIndex = function () {

var fork = require('child_process').fork
var esFork = fork(path.join(__dirname, 'rebuildIndexChild.js'), {
env: { FORK: 1, NODE_ENV: global.env, ELASTICSEARCH_URI: ELASTICSEARCH_URI, MONGODB_URI: global.CONNECTION_URI }
env: {
FORK: 1,
NODE_ENV: global.env,
ELASTICSEARCH_INDEX_NAME: ES.indexName,
ELASTICSEARCH_URI: ELASTICSEARCH_URI,
MONGODB_URI: global.CONNECTION_URI
}
})

global.esRebuilding = true
Expand Down
4 changes: 2 additions & 2 deletions src/elasticsearch/rebuildIndexChild.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ winston.add(winston.transports.Console, {
})

var ES = {}
ES.indexName = process.env.ELASTICSEARCH_INDEX_NAME || 'trudesk'

function setupTimezone (callback) {
var settingsSchema = require('../models/setting')
Expand All @@ -54,7 +55,6 @@ function setupDatabase (callback) {
}

function setupClient () {
ES.indexName = process.env.ELASTICSEARCH_INDEX_NAME || 'trudesk'
ES.esclient = new elasticsearch.Client({
host: process.env.ELASTICSEARCH_URI,
pingTimeout: 10000,
Expand Down Expand Up @@ -229,7 +229,7 @@ function crawlUsers (callback) {
stream
.on('data', function (doc) {
count += 1
bulk.push({ index: { _index: 'trudesk', _type: 'doc', _id: doc._id } })
bulk.push({ index: { _index: ES.indexName, _type: 'doc', _id: doc._id } })
bulk.push({
datatype: 'user',
username: doc.username,
Expand Down

0 comments on commit 79742ee

Please sign in to comment.