imports/api/elastic/server/taxons.js
/**
 * @description
 *
 * @param {Object} taxons - An array of taxons from the Taxons MongoDB
 * @return The result of the ES bulk query
 */
@description
@param {Object} taxons - An array of taxons from the Taxons MongoDB
@return The result of the ES bulk query
@description @param { Object } taxons - An array of taxons from the Taxons MongoDB @return The result of the ES bulk query
function bulkIndex (taxons) {
  console.log('Enter in bulkIndex');
  return new Promise(function (resolve, reject) {
    var bulkArray = [];
    taxons.map(function (doc) {
      bulkArray.push({
        index: {
          _index: _indexName,
          _type: doc.type,
          _id: doc._id
        }
      });
      bulkArray.push({
        name: doc.name,
        name_fr: doc.i18n.fr.name,
        name_zh: doc.i18n.zh.name,
        skill_suggest: { input: [doc.name], payload: { _id: doc._id } }
      });
    });
    Elastic.bulk({body: bulkArray}, function (err, res) {
      if (err) { console.log('Err: ',err); reject(err); }
      else {  ;resolve(true); }
    })
  });
}
function bulkIndex ( taxons ) { console . log ( 'Enter in bulkIndex' ) ; return new Promise ( function ( resolve , reject ) { var bulkArray = [ ] ; taxons . map ( function ( doc ) { bulkArray . push ( { index : { _index : _indexName , _type : doc . type , _id : doc . _id } } ) ; bulkArray . push ( { name : doc . name , name_fr : doc . i18n . fr . name , name_zh : doc . i18n . zh . name , skill_suggest : { input : [ doc . name ] , payload : { _id : doc . _id } } } ) ; } ) ; Elastic . bulk ( { body : bulkArray } , function ( err , res ) { if ( err ) { console . log ( 'Err: ' , err ) ; reject ( err ) ; } else { ; resolve ( true ) ; } } ) } ) ; }
@description
 @param {Object} taxons - An array of taxons from the Taxons MongoDB
 @return The result of the ES bulk query
@description @param { Object } taxons - An array of taxons from the Taxons MongoDB @return The result of the ES bulk query
// Format the data /*console.log('All right');*/