<commit_before>/**
 * Load dependencies
 */

var http = require('http'),
   errorParser = require('./error/parser'),
   query = require('./query'),
   format = require('./util/format');

/**
 * Factory to create an instance of Client (Exposed)
 * 
 * @param {Object} host - IP address or host address of the Solr Server
 * @param {Object} port - port of the Solr Server
 * @param {Object} core -
 * @param {Object} path - path used for send requests to the Solr Server
 *
 * @return {Client Object}
 */
exports.createClient = function(host, port, core, path){
  var options = { 
      host : host || '127.0.0.1',
      port : port || '8983',
      core : core || '',
      path : path || '/solr'
   };
  return new Client(options);
}

/**
 *
 * @constructor
 * @this {Client}
 * @param {Object} options - Set of parameters used for the connection to the Solr Server
 * 
 */
 
var Client = function(options){
   this.options = options;
   this.data = {};
   this.adds = [];
   this.autoCommit = false;
   this.updateEach = 1;
}

/**
 * Add (a) document(s) to the Solr Database
 * 
 * @param {Object} doc - Document added to the Solr Database
 * @param {Function} callback - Function to execute when the Solr Server responds or an error occurs
 *
 * @return {Client Object} 
 */ 

Client.prototype.add = function(doc,callback){
   var self = this;
   this.adds.push(doc);
   if(this.adds.length >= this.updateEach){
      this.update(this.adds,callback);
      this.adds = [];
   }
   return self;
}

/**
 * Add last documents to the Solr Database still kept in the array of added document (usefull when you ask the client to    updateEach X documents, call this function to be sure every single document add are now update on the Solr Database)
 *
 * @param {Function} callback - Function to execute when the Sorl's Server responds or an error occurs
 *
 * @return {Client Object}  
 */ 
 
Client.prototype.purgeAdd = function(callback){
   if(this.adds.length > 0){
      this.update(this.adds,callback);
      this.adds = [];
   }else{
      var err = 'SORL_CLIENT:Nothing to purge. Add update clear';
      callback(null,err);
   }
}<commit_msg>Renamed purgeAdd method by flashAdd. Closed #2<commit_after>/**
 * Load dependencies
 */

var http = require('http'),
   errorParser = require('./error/parser'),
   query = require('./query'),
   format = require('./util/format');

/**
 * Factory to create an instance of Client (Exposed)
 * 
 * @param {Object} host - IP address or host address of the Solr Server
 * @param {Object} port - port of the Solr Server
 * @param {Object} core -
 * @param {Object} path - path used for send requests to the Solr Server
 *
 * @return {Client Object}
 */
exports.createClient = function(host, port, core, path){
  var options = { 
      host : host || '127.0.0.1',
      port : port || '8983',
      core : core || '',
      path : path || '/solr'
   };
  return new Client(options);
}

/**
 *
 * @constructor
 * @this {Client}
 * @param {Object} options - Set of parameters used for the connection to the Solr Server
 * 
 */
 
var Client = function(options){
   this.options = options;
   this.data = {};
   this.adds = [];
   this.autoCommit = false;
   this.updateEach = 1;
}

/**
 * Add (a) document(s) to the Solr Database
 * 
 * @param {Object} doc - Document added to the Solr Database
 * @param {Function} callback - Function to execute when the Solr Server responds or an error occurs
 *
 * @return {Client Object} 
 */ 

Client.prototype.add = function(doc,callback){
   var self = this;
   this.adds.push(doc);
   if(this.adds.length >= this.updateEach){
      this.update(this.adds,callback);
      this.adds = [];
   }
   return self;
}

/**
 * Add last documents to the Solr Database still kept in the array of added document (usefull when you ask the client to    updateEach X documents, call this function to be sure every single document add are now update on the Solr Database)
 *
 * @param {Function} callback - Function to execute when the Sorl's Server responds or an error occurs
 *
 * @return {Client Object}  
 */ 
Client.prototype.flashAdd = 
Client.prototype.purgeAdd = function(callback){
   if(this.adds.length > 0){
      this.update(this.adds,callback);
      this.adds = [];
   }else{
      var err = 'SORL_CLIENT:Nothing to purge. Add update clear';
      callback(null,err);
   }
}
{'fraction_non_alphanumeric': 0.12976573265962332, 'fraction_numerical': 0.005741846577859439, 'mean_word_length': 3.0511627906976746, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3974146', 'n_tokens_mistral': 1346, 'n_tokens_neox': 1312, 'n_words': 465}