Systemmanic
Systemmanic

Reputation: 3130

Spring Data Solr ConverterNotFoundException

I'm trying to configure Solr (with Multicore Support) in my application and I get a ConverterNotFoundException whenever I try and register converters.

I've stepped through and can see the query being executed and documents being returned. Just the converters not being found.

I followed the example from the official docs here.

Hopefully someone can shed some light on what's going on as examples are hard to find and the docs aren't overly clear about adding converters when using multicoreSupport=true.

@Configuration
@EnableSolrRepositories(
        multicoreSupport = true,
        basePackages = {"uk.co.foo.bar.repository"})
public class SolrConfig {

    @Resource
    private Environment environment;

    @Bean
    public SolrClient solrClient(HttpClient httpClient) {
        String solrHost = environment.getRequiredProperty("solr.host");
        return new HttpSolrClient(solrHost, httpClient);
    }

    @Bean
    public HttpClient httpClient() {
        ModifiableSolrParams params = new ModifiableSolrParams();
        params.set(HttpClientUtil.PROP_BASIC_AUTH_USER, "user");
        params.set(HttpClientUtil.PROP_BASIC_AUTH_PASS, "pass");
        return HttpClientUtil.createClient(params);
    }

    @Bean
    public SolrConverter solrConverter(CustomConversions customConversions){
        MappingSolrConverter mappingSolrConverter= new MappingSolrConverter(new SimpleSolrMappingContext());
        mappingSolrConverter.setCustomConversions(customConversions);
        return mappingSolrConverter;
    }

    @Bean
    public CustomConversions customConversions(){
        return new CustomConversions(Arrays.asList(new fooConverter(), new barConverter()));
    }

    @Bean
    public SolrTemplate solrTemplate(SolrClient solrClient, SolrConverter solrConverter){
        SolrTemplate solrTemplate = new SolrTemplate(solrClient);
        solrTemplate.setSolrConverter(solrConverter);
        return solrTemplate;
    }
}

Upvotes: 0

Views: 730

Answers (1)

Christoph Strobl
Christoph Strobl

Reputation: 6736

Having multicore support enabled currently does not allow to register global CustomConverters. Unfortunately there's no workaround available. I'll take care of DATASOLR-173 to get this fixed.

Upvotes: 2

Related Questions