Channels ▼
RSS

JVM Languages

Apache Solr



Susan and Allahbaksh work for Infosys Technologies Ltd. in Bangalore, India.


Apache Solr (a name derived from "Searching on Lucene") is an indexing and searching server with a web-services-like API. It is an enterprise-ready Lucene-based search server that supports faceted searching, hit highlighting, index replication, and distributed search, and provides search results in multiple output formats (XML/XSLT and JSON). Solr uses Representational State Transfer (REST) by default for indexing and searching, and the latest version of Solr is 1.4.0.

Advantages of Solr

Solr is an open source Apache project that uses Lucene internally and posseses the following properties:

  • Solr can replicate an index on multiple servers. Replication is OS independent so you can replicate the same index on a Windows platform as well as in Linux. Moreover, the indexes can be configured to operate in sync: If any of the indexes is modified, the other copies of that index get updated automatically.
  • Solr supports distributed search by performing indexing in various machines and merging the results.
  • Solr Indexing and search can be done simultaneously.
  • Solr features an XML-based schema for managing indexed fields.
  • Solr supports facet searching (sub-search on a result).

In this article, we discuss about the basic needs in using Solr, like setup, indexing and querying etc. The advanced topics like facet search, replication and distributed search will be covered in another separate article.

Setting up Solr

Download Solr from http://apache.inetbridge.net/lucene/solr/1.4.0/apache-solr-1.4.0.zip. Solr installation merely requires unzipping the file and extracting the zip contents into a folder, which will be referred to by the environment variable SOLR_HOME.

Solr by default comes with a jetty servlet container. We can start the jetty server by executing the start .jar from the "example" sub-folder in SOLR_HOME in command prompt:

SOLR_HOME here is D:\apache-solr-1.4.0. 

This execution starts the jetty servlet container on port 8983 (default port). Later, we can access the solr interface at http://localhost:8983/solr/admin. Solr stores its config and index details by default in the "example\solr" folder.

We can also deploy Solr as a web app in any servlet container such as Jetty, Resin, Tomcat etc. Assuming JETTY_HOME is the location where jetty is installed, the procedure to deploy in Jetty will be:

    1. Copy solr.war from SOLR.HOME/example/webapps to JETTY_HOME/webapps.
    2. Start the jetty server along with specification of java system property -Dsolr.solr.home. pointing it to the configuration and index location of Solr as in Figure 1

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


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.
 

Video