I want to have access to multiple/2 repos in one service using spring-data-solr. From Spring Data Solr multiple cores and repository I know 'multicore support via namespace config is unfortunately an open issue'.
Can you please help me with the following example, how can I create custom Repos?
My applicationContext.xml has two Solr Templates defined as below:
<!-- Enable Solr repositories and configure repository base package -->
<solr:repositories base-package="com.ay.api.repository"/>
<!-- Configures HTTP Solr server -->
<solr:solr-server id="solrServer" url="${solr.server.url}"/>
<!-- Configures Solr Events template -->
<bean id="solrEventsTemplate" class="org.springframework.data.solr.core.SolrTemplate">
<qualifier type="solrEventsTemplate"/>
<constructor-arg index="0" ref="solrServer"/>
<constructor-arg index="1" value="${solr.server.events.core.name}"/>
</bean>
<!-- Configures Solr Towns template -->
<bean id="solrTownsTemplate" class="org.springframework.data.solr.core.SolrTemplate">
<constructor-arg index="0" ref="solrServer"/>
<constructor-arg index="1" value="${solr.server.towns.core.name}"/>
</bean>
and I have following repos
@Repository
public class EventDocumentRepositoryImpl implements EventSearchRepository {
@Resource
@Qualifier("solrEventsTemplate")
private SolrTemplate solrEventsTemplate;
...
}
public interface EventDocumentRepository extends EventSearchRepository, SolrCrudRepository<EventDocument, String> {
}
public interface EventSearchRepository { .... }
@Repository
public class TownRepositoryImpl implements TownSearchRepository { ...
@Resource
@Qualifier("solrTownsTemplate")
private SolrTemplate solrTownsTemplate;
...
}
public interface TownRepository extends SolrCrudRepository<TownDocument, String>{}
public interface TownSearchRepository { .... }
and lastly Service looks like following:
@Service
public class SearchEventServiceImpl implements SearchEventService {
@Resource
private EventDocumentRepository eventRepository;
@Resource
private TownRepository townRepository;
.....
}
Can someone please advice how can I modify my code to Implement Custom repositories as mentioned in Spring Data Solr with Solr 4.1 multicores ? as I couldn't understand suggested solution in this thread.
Many thanks in Advance.