Skip to content

Architecture: ParameterStore

jpmckinney edited this page Sep 13, 2010 · 10 revisions

Table of Contents

The ParameterStore, as its name suggests, stores Solr parameters.

The ParameterStore defines functions for getting, setting, and removing Solr parameters. Some Solr parameters – like facet.field and fq – may be specified multiple times, while others – like q and start – may be specified only once. The isMultiple method returns true if the parameter may be specified multiple times.

The following functions, which operate on Solr parameters, behave different depending on whether the parameter may be specified multiple times or only once: get, values, add, remove, find, addByValue, and removeByValue. See the documentation for details.

string returns the Solr parameters as a query string. parseString parses a query string into Solr parameters.

Parameters

Solr parameters are represented as Parameter objects. Parameter defines val, for getting and setting the parameter value; local for getting and setting local parameters; and remove for removing local parameters.

Parameter defines methods used by the ParameterStore string and parseString methods: string, which returns the parameter as a query string key-value pair; parseString, which parses that back into a parameter; valueString, which returns the parameter value as a query string-safe value; and parseValueString, which parses that back into a parameter value.

Available parameters

For a list of possible parameters, please consult the links below:

Exposed parameters

Widgets expose parameters to the user; for example, the demo site‘s tagcloud widget exposes the fq parameter. Whenever the user changes the values of parameters, the application’s state changes. In order for the user to bookmark states and to move between states with the browser’s navigation buttons, each state must be saved. The easiest method is to store the exposed parameters in the URL hash (see the ParameterHashStore class). However, you may implement your own storage method by extending this class.

Extending the ParameterStore

The ParameterStore init abstract method is called by the Manager init method. If extending the ParameterStore class, you may implement its init method to perform any one-time initializations.

Any parameters that your widgets expose to the user as described above, directly or indirectly, should be listed by name under the exposed property. exposedString returns the exposed parameters as a query string.

save is an abstract method, which is called by the Manager in its doRequest method; in other words, it is called once before each request is sent to Solr. The save method should store the values of exposed parameters (the application’s current state), such that the user may bookmark and move between states. ParameterHashStore implements the save method to store the state in the URL hash.

storedString returns the string representation of the application’s current state. ParameterHashStore implements the storedString method to return the URL hash.

If, instead of using ParameterHashStore, you implement your own storage method for exposed parameters, you should only need to implement the save and storedString abstract methods. You may choose to implement load, which, by default, resets the exposed parameters (by calling exposedReset) and calls parseString on the string returned by storedString.

Clone this wiki locally