Channels ▼
RSS

Web Development

Apache Solr


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.

[Click image to view at full size]
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.

[Click image to view at full size]
Figure 8.

Table 1 presents a summary of important Solr items and their locations:

[Click image to view at full size]
Table1.

Conclusion

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.


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.
 
Dr. Dobb's TV