0

I am using spring-data-solr to query indexed Solr data running on a Hadoop cluser. 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 Spring Boot version 1.5.2 with the following dependency: compile('org.springframework.boot:spring-boot-starter-data-solr')

Any help or pointers are appreciated.

manish
  • 19,695
  • 5
  • 67
  • 91
  • Can you add the full declaration for the entity class (including annotations) as well (presumably it is `@SolrDocument public class PartyName { ... }`)? – manish Apr 14 '17 at 08:23

1 Answers1

0

Your suggestion gave me the idea. My model looked like this:

public class PartyName {

@Field("case_status")
private String caseStatus;

private String county;

@Field("court_type")
private String courtType;

private String id;

@Field("in_regards_to")
private String inRegardsTo;

@Field("biz_name")
private String bizName; // business name after parsing name

@Field("first_name")
private String firstName; // person 1st name after parsing name

@Field("last_name")
private String lastName; // person last name after parsing name

@Field("middle_name")
private String middleName; // person middle name after parsing name

private String name; // original name before parsing
private String prefix; // person prefix after parsing name
private String suffix; // person name suffix after parsing name

@Field("party_num")
private Integer partyNumber;

@Field("party_role")
private String partyRole;

@Field("party_status")
private String partyStatus;

@Field("row_of_origin")
private String rowOrigin;

@Field("seq_num")
private Integer seqNumber;

private Integer year;

... getter/setter omitted. } When you suggested for me to post my entity code, I realized I needed to add the following annotation: @SolrDocument(solrCoreName = "party_name") public class PartyName { .. After I did that, the JUnit worked fine. Thanks.