A jQuery library to easily send Solr requests.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



QuerySolr is a small jQuery library for easily sending Ajax Solr requests.

Sending Solr requests

A Solr request can be configured by using option parameters:

  host: "", // the IP or domain where the Solr server runs (default '')
  port: "8983", // the port the Solr server listens (default '8983')
  component: "select", // the query component to use (default 'select')
  params: { // the Solr query params to use (default 'q: *:*"')
    q: "*:*",
    fq: "type:car"
  callback: function(data) { // a callback called after Solr results are received
    // do something with the returned Solr results (in JSON format)
  encodeURI: true // automatically encode the URI (default 'true')

}).query(); // and finally send the request.

The above code would send the following request to Solr:*%3A*&fq=type:car&wt=json&json.wrf=? and then calls the callback with the query result.

Solr helper functions

Additionally there are two helper functions:

  • createDismax to create a dismax expression that can be used in nested queries:

    $.querysolr.createDismax("john", "name") // results in query:"{!dismax qf='name'}john"

The first parameter is the query string itself, the second (optional) parameter is one or more (space separated) fields.

  • escapeLucene to escape special characters of a lucene query string:

    $.querysolr.escapeLucene("string+to-escape") // results in "string\+to\-escape"


Just jQuery (tested with jQuery 1.4.4)


QuerySolr is tested by using qUnit.


Dual licensed under the MIT and GPL licenses: http://www.opensource.org/licenses/mit-license.php http://www.gnu.org/licenses/gpl.html

Copyright(c) 2011 Kai Schlamp