Skip to content

Architectural overview

jpmckinney edited this page Sep 13, 2010 · 30 revisions

AJAX Solr loosely follows the Model-view-controller pattern. The ParameterStore is the model, storing the Solr parameters and, thus, the state of the application. The Manager is the controller; it talks to the ParameterStore, sends requests to Solr, and delegates the response to the widgets for rendering. The widgets, along with any theme functions, are the views, each rendering a part of the interface.

Manager

The manager takes as a parameter either solrUrl – if talking to Solr directly – or proxyUrl – if talking to Solr through a proxy. (Usually, you want to talk to the instance through a proxy, so as not to expose the Solr instance to the Internet.) solrUrl must be the absolute URL to the Solr select servlet, or equivalent.

Manager = new AjaxSolr.Manager({
  solrUrl: 'http://example.solrstuff.org/solrjs/select',
});

The ParameterStore and the widgets attach themselves to the Manager with the setStore and addWidget methods, respectively:

Manager.setStore(new AjaxSolr.ParameterStore());
Manager.addWidget(new AjaxSolr.AbstractWidget({
  id: 'identifier',
  target: '#css-selector'
}));

Once these are attached, the Manager’s init method is typically called, to initialize AJAX Solr. init also calls the init methods of the ParameterStore and widgets:

Manager.init();

Having initialized AJAX Solr, the Manager’s doRequest method is typically called, to send the first request to Solr:

Manager.doRequest();

doRequest calls each widget’s beforeRequest method, in case any widget wishes to perform some action before the request is sent to Solr, e.g. display a throbber. It then calls the executeRequest abstract method to send the request. AJAX Solr is JavaScript framework-agnostic; it only requires an AJAX implementation to send requests to Solr. AJAX Solr is distributed with a Manager.jquery.js file, which implements the executeRequest method using jQuery. Once the Manager receives a response from Solr, it caches the response in its response property, and calls each widget’s afterRequest method, in which widgets will inspect the response and update the interface accordingly.

Clone this wiki locally