The first file we need to define is solr.xml
. This file defines the general configuration of a particular Solr Home
, containing one or more cores (multicore). This turns out to be useful if we want to apply different configurations over the same example, or to play with different examples. This will help us in becoming familiar with multicore from the beginning. Steps for configuring Solr Home are as follows:
solr.xml
file under the path /SolrStarterBook/solr-app/chp02/
:<?xml version='1.0' encoding='UTF-8' ?> <solr> <solrcloud /> </solr>
core.properties
. We can, for example, create a subfolder named simple
under chp02
and put our simple core.properties
file in it:name=simple config=solrconfig.xml schema=schema.xml loadOnStartup=true
In this default example, all we had to do to enable automatic discovery of cores was add the <solrcloud />
XML tag, omitting other configurations that can be added later when we need them. When Solr finds this tag, it will search all the subfolders for a core.properties
file. If a file with that name exists in a directory, Solr will try to load the corresponding core. Note that this file can even be empty, and in that case the values used are the default ones that we have used here, explicitly to fix ideas. In fact the only nondefault value is the name. If the name is not defined, it will be assumed that the name of the folder containing the file is the core name.
Note that if you want to hide a core from the discovery mechanism, you can simply rename the core.properties
file (for example, rename it to something like core.properties.skip
).
Before Solr 4.4, the solr.xml
file syntax was completely different, and this will be deprecated from Solr 5. You can still use the syntax of both the versions in the current version, but you have to expect that the legacy format will be dropped in the near future. However, many examples on the internet and books are still based on this legacy format. So it's important to be able to recognize at least the basic elements for it.
We can reproduce the configuration using the legacy format:
<?xml version='1.0' encoding='UTF-8' ?> <solr persistent='false'> <cores adminPath='/admin/cores' > <core name='simple' instanceDir='simple'config='solrconfig.xml' schema='schema.xml' /> </cores> </solr>
Note how in this case the presence of the core.properties
file is ignored, and every core that we want to load must have an entry in the XML file, as shown in the preceding code example.
As you can imagine, the legacy and current syntax are mutually exclusive. If both are used on the same configuration, an exception is thrown in order to avoid problems from the start.
You can find some more detailed information about legacy parameters on the reference guide at
https://cwiki.apache.org/confluence/display/solr/Legacy+solr.xml+Configuration
18.191.202.240