Searching with Solr
In Solr, the search queries are processed by SolrRequestHandler object. A SolrRequestHandler is a plug-in that defines the logic to be executed for any request.
By default, the query is handled by SolrRequestHandler. We can configure Solr for using other RequestHandlers for different tasks like updating, replication, query, etc., by specifying them in solr config.xml. Additionally, multiple instances of the same SolrRequestHandler class with different configurations can be specified.
For queries, custom query handlers can be specified, but the handler name must be mentioned while querying. If not mentioned, the default query handler will be used. By default, Range, Prefix, Boolean, and Wildcard queries are allowed in Solr.
The output is available in XML format by default. You can enter the query in the Solr UI and the results are displayed in an XML format. The other response handlers include a JSON request handler or your customer response handler.
For example, suppose we query for an employee having ID 1234 (employeeid: 1234). If it matches any of the data in index, then output is shown in Figure 7.
SolrJ provides a searching facility along with the indexing facility. For searching, you simply need to define the server, instantiate and set the query, and send the query to the server to fetch response, as in Figure 8.
Table 1 presents a summary of important Solr items and their locations:
Solr is a wonderful standard library for text searching and indexing. With commercial support from Lucid Imagination and acceptance from Eclipse community, Solr is here to stay.