Skip to content

Tutorial: Send a Solr request without updating widgets

jpmckinney edited this page Apr 14, 2013 · 2 revisions

The following information was contributed by Daniel Lo Nigro.

Sometimes, you want to send a request to Solr that uses some of the parameters in the ParameterStore, without causing all the widgets to update with the response. This is fairly easily done with a few lines of code. The next examples assume you are using the jQuery Manager or equivalent.

Note: If the following code is not inside a widget, replace this.manager with a proper reference to the manager.

Modify a copy of the main parameter store

// Create a new parameter store.
var store = new AjaxSolr.ParameterStore();

// Copy the main parameter store.
store.parseString(this.manager.store.string());

// Make any changes you want to the new parameter store.

this.manager.executeRequest('select', store.string(), function (data) {
    // Process the Solr response.
});

Copy only some parameters from the main parameter store

// Create a new parameter store.
var store = new AjaxSolr.ParameterStore();

// Copy all fq parameters from the main parameter store.
store.addByValue('fq', self.manager.store.values('fq'));

// Make any changes you want to the new parameter store.

this.manager.executeRequest('select', store.string(), function (data) {
    // Process the Solr response.
});