-
Notifications
You must be signed in to change notification settings - Fork 210
Comparison to SolrJS
AJAX Solr is a natural advancement of SolrJS, 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.
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. It can do this, because Solr can return the result set and the data for all facets in a single query.
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. SolrJS doesn’t do either.
As of writing, SolrJS is not fully IE 6, IE 7, and IE 8-compatible. AJAX Solr is.
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.
SolrJS doesn’t provide support for Solr’s highlighting or sorting parameters. AJAX Solr does. AJAX Solr supports AND and OR faceting, ex and tag local parameters, the facet.limit and facet.missing facet parameters on a global and per-field basis, and more.
SolrJS defines a few hooks for modifying a widget’s behaviour. AJAX Solr adds: `afterChangeSelection`, which allows a widget to run some code if one of its filters was set/unset; `startAnimation`/`endAnimation`, which allow you to customize what happens while the AJAX request is being performed, e.g. replace the result set with a loading spinner; `displayQuery`, which allows you to display the current query, filters, sort, etc. to the user.
SolrJS’s functions for selecting/unselecting filters require that you pass in the full list of selected filters. AJAX Solr’s functions just require that you pass in the list of filters that you want to add or remove from the list of selected filters. In other words, with AJAX Solr, you don’t need to know the state of the current list of selected filters; you just add/remove what you want.
In the widgets we’ve written for AJAX Solr, we separate the HTML from the JavaScript by putting all the HTML into “theme” functions using the AjaxSolr.theme API call (inspired by Drupal).
We work hard to ensure that AJAX Solr is DRY-er, more loosely coupled, and easier to read than SolrJS. Consider this quick example:
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 */
});