Solr Enterprise Search Meeting OFBiz (Part – 1)

Pranay PandeyPublished: Updated:

Apache Solr

In my last post Apache Solr Enterprise Search we saw how Solr can help bring modern search capabilities to your business applications. In this post we are going to explain how to install Solr locally on your computer prior to using its enterprise search features within Apache OFBiz.

Setting up Solr Enterprise Search Platform Locally

To get Solr running on your computer here are simple steps to install it, assuming that you already have Java 1.6 or later installed:

1. Download the binary distribution (.zip or .tgz) and extract it. Download Apache Solr 4.7.2 from here.

2. Go to tbe Solr directory and start Solr on the command line. Use the built in Solr example to test it. In the command examples provided  solr-4.7.2 is the home directory of Solr.

$ cd solr-4.7.2/example/

$ java -jar start.jar

3. As you see from the following log messages at or near the bottom, you now have a running version of Solr 4.7.2.

INFO  org.apache.solr.core.SolrCore  ? [collection1] Registered new searcher Searcher@3eeabd2f[collection1] main{StandardDirectoryReader(segments_1:1:nrt)} 12453 [main] INFO  org.eclipse.jetty.server.AbstractConnector  ? Started SocketConnector@0.0.0.0:8983

4. To verify Solr started correctly direct your browser to the Solr administration page at http://localhost:8983/solr. You should see the administration page below.

Apche Solr Enterprise Search Platform Admin Console

Apche Solr Enterprise Search Platform Admin Console

You have now completed the installation. It is easy because Solr is self-contained in a single archive file, all you need to do is extract it.

Behind the scenes, start.jar launched the java web server Jetty, listening on port 8983. Solr comes with an easy to setup example core, a core is composed of a set of configuration files, Lucene index files, and Solr’s transaction log. One Solr server running in Jetty can host multiple cores.

Indexing the Example Documents For Testing Solr Enterprise Search

To start playing with the admin page, you have to first index the example documents that came with the Solr download. When you first start Solr, there are no documents in the index. Its an empty server waiting to be filled with data to search. To get example data into the Solr index you have run these commands:
$ cd solr-4.7.2/example/exampledocs/
$ java -jar post.jar *.xml
You should see the following:
SimplePostTool version 1.5
Posting files to base url http://localhost:8983/solr/update using content-type application/xml..
POSTing file gb18030-example.xml
POSTing file hd.xml
POSTing file ipod_other.xml
POSTing file ipod_video.xml
POSTing file manufacturers.xml
POSTing file mem.xml
POSTing file money.xml
POSTing file monitor.xml
POSTing file monitor2.xml
POSTing file mp500.xml
POSTing file sd500.xml
POSTing file solr.xml
POSTing file utf8-example.xml
POSTing file vidcard.xml
14 files indexed.
COMMITting Solr index changes to http://localhost:8983/solr/update..
Time spent: 0:00:01.060

This indicates the post.jar file successfully sent the XML documents to Solr using HTTP POST. After all the documents are sent to Solr, the post.jar application issues a commit, which makes the example documents findable in Solr. To verify that the example documents were added successfully:

  1. Go to the Solr administration console (http://localhost:8983/solr)
  2. Go to the Core Selector and select collection1.
  3. Now go to the Query page and find all the documents using a query (*:*), you should see the results page below:

Apache Solr Enterprise Search Platform Admin Console Query Page

Now we can have some fun, you can start playing with the example core. You can learn about the Solr Query Syntax by clicking the link in the footer of the Solr admin page or you can directly hit Solr Query Syntax. Solr Documentation and Tutorials can be accessed from the project page.

There will be another post soon on how to use the Solr features with OFBiz. We will be seeing it happening with code with example.

Thanks for taking the time to read this post.

Keep Learning…

Pranay Pandey About Pranay Pandey
Pranay Pandey has been in the software industry since 2006. He specializes in Enterprise Software Design and Development. At HotWax he currently leads the effort of architecting quality software products and training resources. He continues to be dedicated to the Apache OFBiz open source project since 2007 and became a committer in 2014. He leads our internal training programs in Apache OFBiz, ERP and new technologies under the roof of HotWax University. He is an Electronics graduate and has a masters degree in Computer Applications from Rajeev Gandhi Technical University, Bhopal (M.P.) India. He loves learning and sharing knowledge. He believes that one of the keys to success in this industry is to "keep learning". His hobbies are reading, writing, walking, running, cycling, cooking and watching science fiction movies.

Leave a Reply

Your email address will not be published. Required fields are marked *