Skip to content

Commit

Permalink
Merge pull request #9 from abhishekbhattacharyya/master
Browse files Browse the repository at this point in the history
Including an feature to send more than one doc to SOLR in one call
  • Loading branch information
hguillermo committed Dec 17, 2013
2 parents e843e9b + 26a22fe commit 3a48ec9
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lib/client.js
Expand Up @@ -136,6 +136,32 @@ var solrClient = function(init_opts) {
}
};

this.addDocs = function(solrdocs, commit, callback) {
if ((solrdocs != null) && solrdocs.length > 0) {
var _client = _.clone(this._client);
_client.method = 'POST';
if (typeof _client['core'] == 'string') {
_client.path += '/' + _client['core'];
}
_client.path += '/update'
+ (commit == true ? '?commit=true' : '?commit=false');
_client.data = '<add>';
_.each(solrdocs, function(doc) {
if (doc instanceof helios.document) {
return _client.data += doc.toXML();
} else {
return callback(new SolrClientException("Bad Solr Document", doc));
}
});
_client.data += '</add>';
_client.headers = {
'Content-Length': Buffer.byteLength(_client.data),
'Content-Type': 'application/xml'
};
return executeQuery(_client, callback);
}
};

this.updateDoc = function(doc, commit, callback) {
// ---------------------------------------------------------------------------------------------------------------------
// NOTE: Solr has a bug. If there are not fields to update or delete Solr
Expand Down

0 comments on commit 3a48ec9

Please sign in to comment.