Getting Started
|
Notes: If you have already got everything up and running from the Quick Start - The 5 Steps section, then you can skip this section as this expands on that section and goes into finer-grained detail with deeper explanations.
If something is not working, see the When Something Goes Wrong section. |
For this book we are going to be looking at a faceted search engine based on mechanical pencils - in particular 2mm clutch type mechanical pencils.[8] The data used is included with the Panl release package and offers a good learning opportunity to understand
- How to set up a Solr search server,
- How to index data,
- How to run a Panl server, and
- What features are available through configuring the Panl server.
|
IMPORTANT: This is the Getting Started guide for Solr version 9, if you are using a previous version of Panl, ensure that you have the correct Panl release package and the you refer to the Setting up a Solr 7 or 8 server section in the Appendix for how to index data for those versions. |
Downloading the Resources
Apart from a Java version 11 or greater, you will need the following resources
- Download the latest release of Synapticloop Panl - this book is using the solr-panl-9-1.1.1 version:
https://github.com/synapticloop/panl/releases/ - Download the latest version of Apache Solr - this book is using the 9.6.1-slim version:
https://solr.apache.org/downloads.html
Now unzip/untar/untgz the resources into an installation directory. For my installation, I used the following:
The Solr server
On a Windows machine the installation directory was:
C:\java-servers\solr-9.6.1-slim\
whilst on a *NIX the installation directory was:
/Users/synapticloop/java-servers/solr-9.6.1-slim/
Whichever operating system that you are using, throughout this book, this directory is referred to as the SOLR_INSTALL_DIRECTORY.
The Panl server
On a Windows machine the installation directory was:
C:\java-servers\solr-panl-9-1.1.1\
whilst on a *NIX[9] the installation directory was:
/Users/synapticloop/java-servers/solr-panl-9-1.1.1/
Whichever operating system that you are using, throughout this book, this directory is referred to as the PANL_INSTALL_DIRECTORY.
Creating and Starting a Solr Cloud Instance
Run the following command which will start up Solr in cloud mode with default values i.e. two replicas and two shards per replica, with a default collection of 'gettingstarted'
Windows:
Command(s) |
cd SOLR_INSTALL_DIRECTORY
bin\solr start -e cloud -noprompt |
For example, the above command with the Windows installation directory replacement would translate to:
cd C:\java-servers\solr-9.6.1-slim\
bin\start -e cloud -noprompt
*NIX:
Command(s) |
cd SOLR_INSTALL_DIRECTORY
bin/solr start -e cloud -noprompt |
For example, the above command with the *NIX directory replacement would translate to:
cd /Users/synapticloop/java-servers/solr-9.6.1-slim
bin/start -e cloud -noprompt
This will start Solr in cloud mode with all of the defaults - you can check to see that it is up and running by going to the cloud admin console:
http://localhost:8983/solr/#/~cloud,
and you should be presented with a page similar to the following:
Image: The Solr Cloud Admin page
|
Notes: In the above image, under the 'Collections' column in the table, you will see the value 'gettingstarted' - this is the default collection that is set up and can be safely ignored. |
The above shows the two cloud Solr nodes up and running - ignore the values for the moment - now it is time to create the mechanical pencil collection and index the data.
|
Notes: The Solr admin pages off a lot of information for troubleshooting collections and indexes. It is worth your while getting to understand the functionality behind it, however it is beyond the scope of this book. |
Creating a collection
To create a collection, we will be using the schema and data included in the Panl Server Package, which resides in the PANL_INSTALL_DIRECTORY/sample/solr/mechanical-pencils/ directory.
Run the following commands to create a new collection named mechanical-pencils
Windows:
Command(s) |
cd SOLR_INSTALL_DIRECTORY
bin\solr create -c mechanical-pencils -d ↩ |
*NIX:
Command(s) |
cd SOLR_INSTALL_DIRECTORY
bin/solr create -c mechanical-pencils ↩ |
This will create a collection called mechanical-pencils. You can confirm the creation of the new collection on the cloud admin console: http://localhost:8983/solr/#/~cloud, and you should be presented with a page similar to the following:
Image: The Solr Cloud Admin page
|
Notes: In the above image, two collections are now shown, 'gettingstarted' and 'mechanical-pencils', you can safely ignore the 'gettingstarted' collection. |
Indexing the Data
Now that the collection has been created, it is time to index the data. Data for the mechanical-pencils collection is included in the Panl Server package in the PANL_INSTALL_DIRECTORY/sample/data/ directory.
To index the data:
Windows:
Command(s) |
cd SOLR_INSTALL_DIRECTORY
bin\solr post -c mechanical-pencils ↩ |
*NIX:
Command(s) |
cd SOLR_INSTALL_DIRECTORY
bin/solr post -c mechanical-pencils ↩ PANL_INSTALL_DIRECTORY/sample/data/mechanical-pencils.json |
Starting The Panl Server
Windows:
Command(s) |
cd PANL_INSTALL_DIRECTORY
bin\panl.bat -properties ↩ |
*NIX:
Command(s) |
cd PANL_INSTALL_DIRECTORY
bin/panl -properties ↩ |
http://localhost:8181/panl-results-viewer/
You will be presented with the following page:
Image: The In-Built Panl Results Viewer web app showing the list of available collection/FieldSet configurations
Select one of the collection/FieldSet URLs - for example
http://localhost:8181/panl-results-viewer/mechanical-pencils/firstfive
and start searching, sorting, faceting and sorting.
When Something Goes Wrong
|
Tips: Ensure that you have the latest version of this book. Whilst the commands shouldn't change, they might... |
Alas, not everything always goes according to plan, when attempting to troubleshoot the instructions, the base advice is to start with a separate, clean Solr installation (as opposed to using an existing Solr installation) so that there are no errant configuration problems.
This will ensure that:
- All default ports are available for both the Solr (ports 8983, 7574, 9983) and Panl (port 8181) servers - which are referenced throughout this book, and
- No conflicting configuration is used from previous installations
Restarting the Solr Panl tutorial process
- Stop all running Solr instances
See the 'Stopping Solr' section below, make sure that you stop all instances, whether it is for this process, or any other pre-existing installations that you may have - Create separate Solr and Panl installations
Re-download the installation files if necessary and unzip/un-tgz to a new, clean installation directory - Re-run the tutorial, ensuring that you are using the correct values for
SOLR_INSTALL_DIRECTORY, and
PANL_INSTALL_DIRECTORY
Stopping Solr
Windows:
Command(s) |
cd SOLR_INSTALL_DIRECTORY
bin\solr stop -all |
*NIX:
Command(s) |
cd SOLR_INSTALL_DIRECTORY
bin/solr stop -all |
This will stop all instances of the Solr servers that are running in cloud mode.
|
IMPORTANT: If you have multiple Solr installations, you will need to make sure that you run the stop command from the Solr installation directory that it was started from. |
Deleting a collection
Windows:
Command(s) |
cd SOLR_INSTALL_DIRECTORY
bin\solr delete -c mechanical-pencils |
*NIX:
Command(s) |
cd SOLR_INSTALL_DIRECTORY
bin/solr delete -c mechanical-pencils |
You will then need to re-create the collection, and re-index the data.
Re-Starting Solr
Windows:
Command(s) |
cd SOLR_INSTALL_DIRECTORY
bin\solr start -cloud -p 8983 -s "example\cloud\node1\solr"
bin\solr start -cloud -p 7574 -s "example\cloud\node2\solr" -z localhost:9983 |
*NIX:
Command(s) |
cd SOLR_INSTALL_DIRECTORY
bin/solr start -cloud -p 8983 -s "example/cloud/node1/solr"
bin/solr start -cloud -p 7574 -s "example/cloud/node2/solr" -z localhost:9983 |
Worst-case scenario
In the worst case scenario - you may have to look at the log files which can be found in the following directories:
- SOLR_INSTALL_DIRECTORY/example/cloud/node1/logs, and
- SOLR_INSTALL_DIRECTORY/example/cloud/node2/logs
If nothing else seems to work, delete the solr collection.
- Ensure that Solr is stopped,
- Delete the SOLR_INSTALL_DIRECTORY/example/cloud/node1, and
SOLR_INSTALL_DIRECTORY/example/cloud/node2 directories (including all of their contents[10]). - Re-create the Solr cloud instance,
- Re-create the collection(s), and
- Re-index the data
Next Steps
For indexing additional data, see the Additional Data section, for deeper understanding of how to set up a new collection and search page from scratch see the A Walkthrough Example - The Book Store section.
~ ~ ~ * ~ ~ ~