Solr Core Discovery


By: Dikshant Shahi | May 15, 2015

How does Solr discover a core?

If you are a seasoned Solr developer and yet to migrate to latest releases, your answer might be ‘by registering the core by adding <cores> element in solr.xml’. Yes, this is absolutely correct for releases < Solr 4.4 and even  works good for newer 4.x releases but is supposed to fail with 5.x releases.

Solr 5.x no longer supports <cores> element. It introduces the core discovery mechanism. To migrate from legacy mechanism of <cores> element, you need to start with removing all the <cores>  entry and creating a file core.properties in the instanceDir of the core.

Solr discovers the core on the basis of core.properties file and this file can exist in any deep directory i.e. even in a sub-directory and that directory will be treated as core instanceDir. Below is an example, in which core1 is the core instanceDir and is three level deep.

./dir1/dir2/dir3/core1/core.properties

The core.properties file is a Java properties file and the simplest file can be empty file, if your core runs with all default settings. If you want to configure properties for the core, you can do it in this file as below.

core.properties:

name=core1

config=solrconfig.xml

schema=schema.xml

In the above example, we provided the default name for config and schema but if you want,  you can rename it to any preferred name.

You can also define you custom properties in this file and use it across the core like in solrconfig.xml, schema.xml etc. But this feature has an open bug SOLR-5931 and the properties doesn’t reload on reloading the core. Hence, don’t configure the properties which change frequently until the issue is resolved. But definitely core discovery provides very convenient and easy approach  for discovering core and also a central point for maintaining properties.

 

Dikshant Shahi (8 Posts)

Dikshant works as Solution Architect at The Digital Group. He takes interest in Semantic Search, Information Retrieval, Natural Language Processing and Machine Learning. He is the author of book "Apache Solr: A Practical Approach to Enterprise Search".


This post has been viewed 2,599 times

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>