spring-data-solr
spring-data-solr copied to clipboard
Fixes DATASOLR-264 - Extended SolrTemplate to support multicore operations
Firstly, I've created a new interface called MulticoreSolrOperations
which is similar to SolrOperations
, but, all methods in MulticoreSolrOperations
accept a coreName
parameter i.e. to specify a solr core over which the operation should be performed. SolrTemplate
now implements MulticoreSolrOperations
and it heavily depends on the SolrClientFactory
instance. It means that these operations would be executed on the specified Solr core only if SolrTemplate
was wired with MulticoreSolrClientFactory
and not HttpSolrClientFactory
(as it returns the same SolrClient instance for any coreName given to its getSolrClient
method).
The fix for the issue didn't have anything to do with what I've described above i.e. it was just about extracting the coreName
from SolrDocument
annotated over SolrsearchRequestProductData
while executing SolrTemplate#queryForFacetPage(query, SolrsearchRequestProductData.class)
and performing the operation over that core. To be consistent, I modified all implemented methods of SolrOperations
inside SolrTemplate
to use the newly created SolrClientUtils#resolveSolrCoreName(Class<?> type, String defaultCoreName)
method wherever a Class
was present in the method parameters. This however didn't seem to be a complete solution as not all methods were, in a sense, "multicore" supportive i.e. methods like commit
couldn't operate on a core other than the default one. This was the reason for creatingMulticoreSolrOperations
.
Please review and pull if the solution looks fine. My CLA number is 149720151120072904.
Thanks, Venil Noronha