A SolrRequestHandler is a Solr Plugin that defines the logic executed for any request.
Contents
Configuration
Multiple handlers (including multiple instances of the same SolrRequestHandler class with different configurations) can be specified in the solrconfig.xml
<requestHandler name="foo" default="true" class="my.package.CustomRequestHandler" />
<requestHandler name="bar" class="my.package.AnotherCustomRequestHandler">
<!-- 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="/baz" class="my.package.AnotherCustomRequestHandler">
<requestHandler name="/update/my-pdf-reader" class="my.package.MyPdfHandler">
Handler Resolution
Clients access specific SolrRequestHandlers either with the 'qt' parameter on a request for the /select/ url, or through the path registered in solrconfig.xml. For the above example, running on localhost:8983/solr/, you could access:
http://localhost:8983/solr/select/?qt=foo&... http://localhost:8983/solr/select/?qt=bar&... http://localhost:8983/solr/baz?... http://localhost:8983/solr/update/my-pdf-reader?...
Solr selects a handler to process a request using the following steps...
- look for a handler with a name matching the request (either the full path or the "qt")
look for a handler configured with default="true"
- look for a handler configured with name="standard"
use an anonymous instance of StandardRequestHandler
Note! If your solrconfig.xml contains requestHandlers with the name= "/select", "/update", or "/admin" you will short circuit the standard request processing and use your own logic.
Content Streams
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...