Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

Using spring-data-solr to Query Indexed Data on CDH 5.10

avatar
Contributor
Spoiler
I am using spring-data-solr to query indexed solr data running on a Cloudera Hadoop cluser(CDH5.10) . The name of my collection is party_name. Below is the code I used to configure the Cloud client:

@Configuration @EnableSolrRepositories(basePackages = { "org.nccourts.repository" }, multicoreSupport = true) public class SpringSolrConfig {

@Value("${spring.data.solr.zk-host}")
private String zkHost;

@Bean
public SolrClient solrClient() {
    return new CloudSolrClient(zkHost);
}

@Bean
public SolrTemplate solrTemplate(CloudSolrClient solrClient) throws Exception {
    solrClient.setDefaultCollection("party_name");
    return new SolrTemplate(solrClient);
}
}

When I run my junit test, I am getting the following exception: org.springframework.data.solr.UncategorizedSolrException: Collection not found: partyname; nested exception is org.apache.solr.common.SolrException: Collection not found: partyname at org.springframework.data.solr.core.SolrTemplate.execute(SolrTemplate.java:215)

at org.springframework.data.solr.core.SolrTemplate.executeSolrQuery(SolrTemplate.java:1030)

Note the Collection not found: partyname, but the collection name I entered is party_name.
I am using springboot version 1.5.2 with the following dependency: compile('org.springframework.boot:spring-boot-starter-data-solr')

Any help or pointers are appreciated.

 
1 ACCEPTED SOLUTION

avatar
Contributor

By adding the annotation to my model(document) the problem was resolved.

@SolrDocument(solrCoreName = "party_name")
public class PartyName {

....

}

View solution in original post

1 REPLY 1

avatar
Contributor

By adding the annotation to my model(document) the problem was resolved.

@SolrDocument(solrCoreName = "party_name")
public class PartyName {

....

}