Handy method to initialise SolrJ client based on configuration properties;
private void initSolrClient() {
if (conf.kerberos().isEnabled()) {
System.setProperty("java.security.auth.login.config", conf.kerberos().confPath());
HttpClientUtil.addConfigurer(new Krb5HttpClientConfigurer());
}
if (conf.solr().getMode() == SolrProperties.Mode.STANDALONE) {
this.solr = new HttpSolrClient.Builder(conf.solr().url()).build();
}
if (conf.solr().getMode() == SolrProperties.Mode.CLOUD) {
this.solr = new CloudSolrClient.Builder().withZkHost(conf.solr().zookeepers()).build();
}
}
REMOTE with Kerberos:
solr.conf.mode=CLOUD
solr.conf.zookepers=zookeeper-01.mydomain.com:2181,zookeeper-02.mydomain.com:2181,zookeeper-03.mydomain.com:2181/solr
kerberos.enabled=true
kerberos.confPath=/my/path/to/krb5/jaas-client.conf
LOCAL development:
solr.conf.mode=STANDALONE
solr.conf.url=http://localhost:8983/solr
kerberos.enabled=false