Solr client for node.js

A solr client for indexing, adding, deleting,committing and searching documents within an Apache Solr installation (version>=3.2).

Latest Update from Github

Loading...
Loading...

Module dependencies

HTTPError

Hide Source
var HTTPError = require('httperror'),
   util = require('util');

Expose SolrError

module.exports

Hide Source
module.exports = SolrError;

Create a new SolrError

SolrError()

@returnSolrError
@apiprivate
Hide Source
function SolrError(req,res,htmlMessage){
   var message = '';
   if(htmlMessage){
      var matches = htmlMessage.match(/<pre>([\s\S]+)<\/pre>/);
      message = decode((matches || ['', htmlMessage])[1].trim());
   }
   HTTPError.call(this, req, res, message);
   Error.captureStackTrace(this,arguments.callee);
   this.name = 'SolrError';
}

util.inherits(SolrError, HTTPError);

Decode few HTML entities: &<>'"

decode()

@param{ String }str-
@returnString
@apiprivate
Hide Source
function decode(str) {
  return str.replace(/&/g,'&')
            .replace(/</gm, '<')
            .replace(/>/gm, '>')
            .replace(/'/gm, '\'')
            .replace(/"/gm, '"');
};