A SolrRequestHandler is a Solr Plugin that defines the logic executed for any request.
Multiple handlers (including multiple instances of the same SolrRequestHandler class with different configurations) can be specified in the solrconfig.xml
<requestHandler name="/foo" class="my.package.CustomRequestHandler" /> <!-- initialization args may optionally be defined here --> <lst name="defaults"> <int name="rows">10</int> <str name="fl">*</str> <str name="version">2.1</str> </lst> </requestHandler> <requestHandler name="/update/my-pdf-reader" class="my.package.MyPdfHandler">
Clients access specific SolrRequestHandlers through the remaining URL path (starting with a '/') corresponding with a named request handler (also starting with a '/'). For the above example, running on localhost:8983/solr/, you could access:
Old handleSelect=true Resolution (qt param)
<requestDispatcher> element has a
handleSelect attribute which defaults to false as of Solr 3.6. Before then it was true, and the example solrconfig.xml had it explicitly set to true as well. When it is true, there is an additional dispatch rule that comes into place if the request uses "/select" but there is no request handler by that name. Instead of it being an error, Solr uses the "qt" parameter to lookup the handler by name. In limited cases, 'qt' may start with a leading '/' but that practice should be avoided. If there is no 'qt' parameter then the default handler is chosen.
'qt' can be used to choose a request handler in other cases aside from a new HTTP request. Two others are for the warming queries and also for the ping query, both configured in solrconfig.xml. For these other cases, there is no restrictions on a leading '/'. And in these cases, when 'qt' is not specified, the default handler is chosen.
The default handler is normally the handler named "/select". However another specific handler can be anointed as such with a
default="true" attribute on it, if desired. "standard" was the old default name and will still work but it's legacy/deprecated. If there is no default handler, then most/all cases in which a default one is chosen will instead trigger an error.
When SolrRequestHandlers are accessed using path based URLs the SolrQueryRequest object that contains the parameters of the request may also contain a list of ContentStreams containing bulk data for the request.
Implementing a Request Handler
The easiest way to implement SolrRequestHandler is to extend the RequestHandlerBase class. Also see the list of Request Handlers below for examples.
List of Request Handlers Available
The Javadocs contain a complete list of Request Handlers. Many of which have their own wiki pages...
There are a variety of system information request handlers documented here.