How to Install the Lucene Search Engine using Solr
I’m going to go through the steps necessary to install and start using Solr. I’ve always been interested in trying out Lucene, but I never felt like dealing with writing my own wrapper around the classes. Solr simplifies this by creating a fully working search engine as a web service.
Let’s get started. You’ll need to check to see if Java is up to date. Run the below to find out.
java -version
You need to be running at least Java 1.5. Next is to check to see if Ant is installed. Do that with.
ant -version
I’m doing this on my Mac using Leopard. Here’s some instructions on setting up Ant if you aren’t using Leopard.
Java was up to date, and ant is built in. Sweet. However, I need to install JUnit. I’ll do that first.
Download JUnit. You’ll need to put it somewhere that’s accessible by the $CLASSPATH variable. There’s more information on the JUnit FAQ.
I threw it in /usr/share and left the name as junit-4.4.jar and set my CLASSPATH to point to that file (not the directory)
export CLASSPATH=$CLASSPATH:/usr/share/junit-4.4.jar
I ran that, as well as put it in my /etc/bashrc file (which you must be root to edit) so I don’t have to deal with it again.
Compile Solr
Switch back to the directory containing the solr files, and run:
ant compile
You should see something like this:
Buildfile: build.xml
init-forrest-entities:
checkJunitPresence:
compile:
[javac] Compiling 185 source files to /Users/jhaddad/src/apache-solr-1.2.0/build
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.BUILD SUCCESSFUL
Total time: 3 seconds
I then ran:
ant dist
Which outputted something like this:
Buildfile: build.xml
init-forrest-entities:
checkJunitPresence:
compile:
make-manifest:
[mkdir] Created dir: /Users/jhaddad/src/apache-solr-1.2.0/build/META-INFdist-jar:
[jar] Building jar: /Users/jhaddad/src/apache-solr-1.2.0/dist/apache-solr-1.2.1-dev.jardist-war:
[war] Building war: /Users/jhaddad/src/apache-solr-1.2.0/dist/apache-solr-1.2.1-dev.wardist:
BUILD SUCCESSFUL
Total time: 0 seconds
You can run the example by going to the example directory and running
java -jar start.jar
Then go here: http://localhost:8983/solr/admin/ and check out your admin.
Load a few sample docs by going here:
/example/exampledocs
and running
java -jar post.jar solr.xml monitor.xml
I will post a follow up on how to get Solr running in Tomcat, as well as examples on how to use the server.
5 Responses to How to Install the Lucene Search Engine using Solr
Leave a Reply Cancel reply
Recent Comments
- Anil on MySQL Triggers Tutorial
- Ashish on MySQL Triggers Tutorial
- David on iCal Agenda
- jon on IP address geolocation SQL database
- pim on IP address geolocation SQL database
- jnns on Redis Wildcard Delete
- K.C. Murphy on iCal Agenda
- BA on Experts Exchange should be removed from Google search results
- Andrew on Executing multiple curl requests in parallel with PHP and curl_multi_exec
- Stu on Executing multiple curl requests in parallel with PHP and curl_multi_exec
Recent Posts
- New Project: Jester
- Open New Terminal Tip
- Installing MySQLdb on MacOS Lion
- Headless VM Server Using Ubuntu 11.10
- Get rid of Facebook’s Awful Ticker
- Api Tester now hosted on Github
- Trac .11 jQuery bug
- Multiple Filetypes in Vim
- Git Tip: Setting Up Your Remote Server
- Install issue pymongo on OSX (setuptools out of date)
Categories
- amazon (1)
- answerbag (6)
- apache (9)
- apple (8)
- awk (2)
- bbedit (2)
- c++ (3)
- chrome (2)
- cluster (1)
- cocoa (1)
- collective intelligence (1)
- curl (3)
- db2 (1)
- demand media (1)
- ebay (1)
- eclipse (4)
- erlang (13)
- facebook (1)
- fortran (1)
- gen_server (1)
- git (5)
- google (4)
- haddad (1)
- hdf5 (1)
- html (1)
- innodb (1)
- itunes (1)
- java (2)
- jester (1)
- kvm (1)
- launchbar (1)
- leex (1)
- letsgetnuts.com (1)
- libvirt (1)
- links (6)
- linux (27)
- lucene (1)
- mac (16)
- memcached (1)
- misconception (1)
- mobile (1)
- mono (1)
- mssql (1)
- munin (1)
- mysql (31)
- numpy (1)
- oracle (1)
- php (23)
- puppet (4)
- pyparsing (1)
- pytables (1)
- python (11)
- q&a (1)
- quicksilver (1)
- rant (6)
- readynas (1)
- redis (2)
- regex (1)
- replication (1)
- search (1)
- shitty code (1)
- solr (3)
- spaces (1)
- sshfs (1)
- stored procedure (1)
- svn (5)
- textmate (2)
- tips (22)
- trac (1)
- tutorial (4)
- ubuntu (3)
- Uncategorized (4)
- unix (1)
- vim (3)
- virtual box (6)
- vmware (1)
- weird (3)
- wikipedia (1)
- windows (1)
- xcode (1)








small note: this post isn’treally about installing Solr, it’s about *building* Solr from the java source.
If you download the Solr 1.2 release, you can skip almost everything up to the “You can run the example…” line.
http://www.apache.org/dyn/closer.cgi/lucene/solr/1.2
Hmm… that’s interesting. I didn’t even realize it comes prebuilt. I suppose that makes this post sort of useless. Thanks for the head’s up.
What are you thoughts on Lucene? Have you played with Nutch at all?
Hi Josh,
To answer your comment / question:
Solr is a nice nice web wrapper, more focused on the front end and schema/data structure.
Nutch is much more of a back end web spider, though it does have a tiny web sample. It also includes Hadoop for scalability, which is nice but can make debugging a bit more interesting. There’s now some integration between nutch and solr.
And of course Lucene is the engine that is included in both.
32. You could definitely see your expertise in the work you write. The world hopes for even more passionate writers such as you who aren’t afraid to mention how they believe. Always follow your heart.