I have apache solr with multiple cores e.g. currency, country etc... So using Spring Data Solr I can retrieve information from one core. I have got this XML configuration ri
Spring Data now supports multiple cores with their respective repositories.
The multicoreSupport flag needs to be true in @EnableSolrRepositories
annotation and the corresponding document needs to be told what core they belong to. Like:
@SolrDocument(solrCoreName = "currency")
public class Currency
{
// attributes
}
the other class should be
@SolrDocument(solrCoreName = "country")
public class Country
{
// attributes
}
The respective repositories should know what pojo they are working with.
public interface CurrencyRepository extends SolrCrudRepository
{
}
and
public interface CountryRepository extends SolrCrudRepository
{
}
and configuration should be
@Configuration
@EnableSolrRepositories(value = "com.package.name",multicoreSupport = true)
public class SolrConfig
{
@Bean
public SolrServer solrServer() throws Exception
{
HttpSolrServerFactoryBean f = new HttpSolrServerFactoryBean();
f.setUrl("http://localhost:8983/solr");
f.afterPropertiesSet();
return f.getSolrServer();
}
@Bean
public SolrTemplate solrTemplate(SolrServer solrServer) throws Exception
{
return new SolrTemplate(solrServer());
}
}