
Apache Solr for Indexing Data
By :

To test whether your installation was completed successfully, you need to run Solr. Type these commands in the terminal to run it:
$ cd /usr/local/Cellar/solr/4.4.0/libexec/example/ $ java -jar start.jar
After you run the preceding commands, you will see lots of dumping messages/logs on the terminal. Don't worry! It's normal. Just try to fix any error if it is there. Once the messages are stopped and there is no error message, simply go to any web browser and type http://localhost:8983/solr/#/
.
Downloading the example code
You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
You will see following screen on your browser:
Fresh Solr do not contain any data. In Solr terminology, data is termed as a document. You will learn how to index data in Solr in upcoming chapters.
There are multiple ways of installing Solr on a Windows machine. Here, I have explained the way to set up Solr with Jetty running as a service via NSSM:
example
folder.etc
, lib
, logs
, solr
, and webapps
folders and start.jar
to C:\solr
(you will need to create the folder at C:\solr
), as shown in the following screenshot:C:\solr\solr
folder and copy the contents back to the root C:\solr
folder. When you are done, you can delete the C:\solr\solr
folder. See the following image, the selected folder you can delete now:At this point, your C:\solr
directory should look like what is shown in the following screenshot:
C:\solr
and then run java -Dsolr.solr.home=C:/solr/ -jar start.jar
.http://localhost:8983/solr/
, you should see the Solr dashboard.win32
or win64
folder as appropriate and copy nssm.exe
to your C:\solr
folder.C:\solr
, and then run nssm install Solr
.java.exe
as the application located at C:\Windows\System32\
.Dsolr.solr.home=C:/solr/ -Djetty.home=C:/solr/ -Djetty.logs=C:/solr/logs/ -cp C:/solr/lib/*.jar;C:/solr/start.jar -jar C:/solr/start.jar
.net start Solr
.http://localhost:/8983/solr/
.To install Solr on Linux/Unix, you will need Java Runtime Environment (JRE) version 1.7 or higher. Then follow these steps:
.tgz
) from http://www.apache.org/dyn/closer.cgi/lucene/solr/. At the time of writing this book, the latest release was 4.10.1.example
directory, which runs in Jetty. You can use Jetty servlet container, or use your preferred servlet container. If you are using a servlet container other than Jetty and it's already running, then stop that server.olr-4.10.1.war
file from the Solr distribution under the dist
directory to the webapps
directory of your servlet container. Change the name of this file; it must be named solr.war
.solr-4.x.0/example/solr/
, from the distribution to your desired Solr home location.solr.solr.home
Java system property to your Solr home
(for example, using this example jetty setup: java -Dsolr.solr.home=/some/dir -jar start.jar
).servlet
container so that a JNDI lookup of java:comp/env/solr/home
by the Solr web app will point to your Solr Home
.servlet
container in the directory containing ./solr
. The default Solr Home
is solr
under the JVM's current working directory ($CWD/solr
).http://localhost:/8983/solr/
and you will see the Solr dashboard. Now your Solr is up and running.Thus, by the end of the installation, your Solr is up and running. But since we have not fed any data into Solr, it will not index any data. Let's try to insert some example data into our server.
The Solr download comes with example data bundled in it. We can use the same data for indexing as an example. Go to the exampledocs
directory under the example directory. Here, you will see a lot of files. Now go to the command line (terminal) and type the following commands:
$ cd $SOLR_HOME/example/exampledocs/ $ ./post.sh vidcard.xml
Within the post.sh
file, the script will call http://localhost:8983/solr/update
using curl
to post xml
data from the vidcard.xml
file. When the import completes (without any error), you will see a message that looks something like this:
Now let's try to check out our imported data from web browser. Try http://localhost:8983/solr/select?q=*:*&wt=json
to fetch all of the data in your Solr instance, like this:
When you see the preceding data, it means that your Solr server is running properly and is ready to index your desired feed. You will be reading indexing in depth in upcoming chapters.
Change the font size
Change margin width
Change background colour