We’ll be working with Solr in NixMash Spring in upcoming releases using both Embedded Solr and Http Solr Server in their respective Spring Profiles. One of the first things to lock down when working with Solr is the logic behind Embedded Solr paths and Http Solr urls. It can be confusing when getting started, but these few basic tips will help.
Embedded Solr Paths
Embedded Solr is cool, like Embedded Tomcat, because you don’t have to setup a traditional Solr Server. Not that setting up a Solr Server is difficult, but like Forrest Gump will wisely tell you, “one less thing.”
Here’s an example of an Embedded Solr path used in NixMash Spring
Here’s the directory structure. collection1 is our Solr Core, which is the default collection Solr 4.x looks for.
Here are our takeaways from the Embedded Solr Path.
- We point to the Solr Root, or the directory above our Collection.
- We need a solr.xml file in the Embedded Solr Root directory.
- Save yourself the aggravation and use Solr’s default collection1 Collection name. Be sure it has a core.properties file (not core.properties.unloaded.)
- There is nothing else we need to add to our /solr-4.10.4 folder because the heavy lifting is done by our org.apache.solr-core JAR.
Http Solr Urls
This section will be pretty brief. Here’s an Http Solr url used with NixMash Spring in development.
Here’s what we see when we go to the url, the Solr Server Collection home page for our collection1 core. (The collection1 core is preceded by a /# to view on the web.)
Here are our takeaways from the Http Solr Url.
- We point to the Collection itself, not to a parent directory like we did with Embedded Solr
- Make sure the Http Solr Server is running before firing up your Spring App