Comparison to SolrJS

James McKinney edited this page Apr 13, 2013 · 30 revisions

AJAX Solr is a natural advancement of SolrJS (now defunct), a JavaScript library initially developed by Matthias Epheser as a 2008 Google Summer of Code project. Despite its many merits, it wasn’t production-ready and was in need of maintenance. Below, we outline the improvements we’ve made over SolrJS.

Efficiency

SolrJS executes a separate request for each of its widgets. This is inefficient, as you may have many widgets for faceting on date, language, location, price, category, etc. and at least one widget for displaying results. AJAX Solr performs a single AJAX request.

Browser support

AJAX Solr supports the back button and bookmarking (using the fragment identifier). You can add a filter or change your query, and click the back button to undo your changes. If you want to save your filtered result set, you just need to bookmark the page. As of writing, SolrJS is not fully IE 6, IE 7, and IE 8-compatible. AJAX Solr is. [Documentation]

Security

SolrJS requires that your Solr instance be publicly accessible. AJAX Solr was built under the assumption that you may want to proxy requests to your Solr instance, e.g. to limit what information the user has access to. AJAX Solr gives you the option.

Solr support

SolrJS doesn’t provide support for Solr’s highlighting or sorting parameters, among others. AJAX Solr supports all features of Solr, including spell check, spatial local parameters, local parameters, facet parameters on both global and per-field bases, and more.

Simplicity

In SolrJS, the management of Solr parameters is split between the manager and its widgets. In AJAX Solr, the management of Solr parameters is unified in the ParameterStore, which provides a rich API for getting, setting, and removing Solr parameters. In SolrJS, the AbstractWidget, from which all widgets inherit, defines many methods which may not apply to your inheriting widgets. In AJAX Solr, the AbstractWidget defines only three abstract methods: init, which is run once when AJAX Solr is initialized, beforeRequest, which is run before every request to Solr, and afterRequest which is run after every request to Solr.

Richer API

In addition to the ParameterStore mentioned above, AJAX Solr comes with AbstractFacetWidget, which defines many convenient methods useful to faceting widgets, AbstractTextWidget, which does the same for free-text widgets, PagerWidget, a pagination widget which works out-of-the-box, and more.

Clean code

We work hard to ensure that AJAX Solr is DRY-er, more loosely coupled, and easier to read than SolrJS. Consider these common examples:

Adding a fq parameter in a SolrJS widget:

$('<a></a>').text(value).attr('href', 'javascript:solrjsManager.selectItems("' + this.id + '", \
[ new jQuery.solrjs.QueryItem({ field:"' + this.field + '", value: "' +  value + '"}) ])');

Adding a fq parameter in an AJAX Solr widget:

$('<a></a>').text(value).click(this.clickHandler(value));

Widget inheritance in SolrJS:

jQuery.solrjs.AbstractClientSideWidget = jQuery.solrjs.createClass('AbstractWidget', {
  /* key/value pairs */
});

Widget inheritance in AJAX Solr:

AjaxSolr.AbstractFacetWidget = AjaxSolr.AbstractWidget.extend({
  /* key/value pairs */
});